简体   繁体   中英

Open New Window, Pause 5 Secs, Redirect, Pause 5 Secs, Redirect, Repeat

是否有可能打开打开窗口的按钮,该页面在页面加载时重定向到mysite.com,然后在mysite.com上等待指定的时间,然后重定向并重复?

You could have the popup contain an <iframe> , and control the target in an JavaScript timer within the popup page, or and I have not tested this, get the handle of the popup and try to change the window.location of that window.

<iframe> method

<html>
    <head>
        <script language="javascript" type="text/javascript">
        var urls = new Array("p1.html","p2.html");
        var currentUrl = 0;
        var interval = setInterval("updateFrame()", 1000);
        function updateFrame() {
            currentUrl = currentUrl == 0 ? 1 : 0;
            document.getElementById("container").src = urls[currentUrl];
        }
        </script>
    </head>
    <body>
        <iframe id="container" frameborder="0" width="100%" height="100%"></iframe>
    </body>
</html>

Here you need to replace "p1.html","p2.html" with your own urls. You'll also need to change currentUrl = currentUrl == 0 ? 1 : 0; currentUrl = currentUrl == 0 ? 1 : 0; if you have more than two in your array. The 1000 refers to milliseconds - change to 5000 for 5 seconds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM