网页实现输入固定前缀,以及打开数量打开固定数量的网页

时间:2024-06-02 07:37:51
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>连续打开网页优化版</title> </head> <body> <input type="text" id="base_url" placeholder="请输入链接前缀格式:http://abc" style="width: 300px"> <input type="number" id="num_of_links" placeholder="请输入需要打开的数量"> <button onclick="openLinks()">打开链接</button> <script> function openLinks() { var base_url = document.getElementById("base_url").value; var num_of_links = parseInt(document.getElementById("num_of_links").value); for (var i = 1; i <= num_of_links; i++) { var url = base_url + i + ".com"; window.open(url); } } </script> </body> </html>