Javascript打开一个新页面(一个或多个),等待它加载,然后关闭它

时间:2014-04-28 19:20:53

标签: javascript arrays

我正在编写一个应用程序,可以在特定的时间间隔内“破坏”网站上的线程。应用程序查看多个输入框,如果每个输入框都有值,则会执行window.open命令来加载页面。然后关闭页面。我遇到的问题是我没有看到任何方法在每次执行后暂停我的for循环,所以页面在关闭之前从未实际加载。有任何想法吗?这是代码。

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>Reoccuring Open</title>
</head>
<body>
    <input id="Bump0" type="text" /><br />
    <input id="Bump1" type="text" /><br />
    <input id="Bump2" type="text" /><br />
    <input id="Bump3" type="text" /><br />
    <input id="Bump4" type="text" /><br />
    <input id="Bump5" type="text" /><br />
    <input id="Bump6" type="text" /><br />
    <input id="Bump7" type="text" /><br />

<input type="button" id="btnStartReoccure" value="Start" onclick="fncSetInterval()"/> <br />
<br />
    If Checked will continue to run<input type="checkbox" id="chxReoccure" />
</body>
</html>

<script type="text/javascript">

    function fncSetInterval() {
        //alert("Set interval x " + x);
        i = 14410000; // 4 hours and some extra
        var bumpsValue = new Array;

        for (x = 0; x < 8; x++)
            {
            if (document.getElementById("Bump" + x).value == null || document.getElementById("Bump" + x).value == "") {
                break;
            }
            bumpsValue[x] = document.getElementById("Bump" + x).value;

            window[x] = window.open("http://www.somewebpage.com/bump.php?t=" + bumpsValue[x]);

        }

        window.setInterval(function(){fncRunReOccur()},i);

    }



    function fncRunReOccur() {

        //var RecURL = document.getElementById("ReoccuranceURL").value;
        //alert("(document.getElementById.value " + (document.getElementById("chxReoccure").checked));
        if (document.getElementById("chxReoccure").checked == true) {

        }
    }

    function fncSleep(millis, callback) {
        setTimeout(function ()
        { callback(); }
        , millis);
    }

</script>

0 个答案:

没有答案
相关问题