-1

I just want open popup and close it after 20s. If there more variables I need open more popups for loading page and after 20s each window close it. I have something like this but its only opens window and not closing it.

<?php
foreach($data as $value){
$var = substr(str_shuffle(str_repeat("abcdefghijklmnopqrstuvwxyz", 5)), 0, 5);
$message=$value->url;
echo '<script>(function() {
   var '.$var.' = window.open("'.$message.'");
   setTimeout(function() {
   '.$var.'.close();
   }, 20000);
   })();</script>';
}

Is there chance open popup individually and close it individually too?

falinsky
  • 7,229
  • 3
  • 32
  • 56

1 Answers1

1

I know what you want, try this one, I've tried this and it works

<html>
<head>
    <script>
        function call()
        {
            popup = window.open('http://www.google.co.in');         
            setTimeout(wait, 20000);
        }   
        function caller()
        {
            setInterval(call, 20000);
        }
        function wait()
        {
            popup.close();
        }
    </script>
</head>
<body onload="caller();">
</body>
</html>