window.close没有关闭窗口

时间:2014-08-09 16:11:14

标签: javascript

尝试在每5分钟后打开一个新的浏览器窗口,在此之前关闭任何浏览器     窗口alredy打开..但是window.close似乎没有关闭..

<html>

<head>
    <script>
        function mytimeout() {

            window.open("http://www.starsports.com/ssplus/cricket/index.html?v=1344487");
            window.setInterval(myFunc, 310000);
        }

        function myFunc() {


            window.close();

            window.open("http://www.starsports.com/ssplus/cricket/index.html?v=1344487");

        }
    </script>
</head>

<body onload="mytimeout()">
</body>

</html>

1 个答案:

答案 0 :(得分:1)

<html>

<head>
    <script>

        var mywindow;

        function mytimeout() {

            mywindow = window.open("http://www.starsports.com/ssplus/cricket/index.html?v=1344487");
            window.setInterval(myFunc, 310000);
        }

        function myFunc() {


            mywindow.close();

            mywindow = window.open("http://www.starsports.com/ssplus/cricket/index.html?v=1344487");

        }
    </script>
</head>

<body onload="mytimeout()">
</body>

</html>