techspl
techspl

Reputation: 43

window.close is not closing the window

Am trying open new browser window after every 5 minutes,before that am closing if any browser window alredy opened..But window.close is not closing it seems..

<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>

Upvotes: 0

Views: 189

Answers (1)

Donal
Donal

Reputation: 32713

<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>

Upvotes: 1

Related Questions