Use setTimeout to close a window - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setTimeout

Description

Use setTimeout to close a window

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Pandora</title> 
   </head> 
   <body onload="pandoraFunction(); setTimeout('closeFunction()', 3000)"> 
      <script>
            function pandoraFunction() {
              window.open('http://www.java2s.com','window','menubar=yes,screenX=0,screenY=0,top=0,left=0,location=no,status=no,toolbar=no,scrollbars=yes,resizable=no,width=' + (screen.width - 10) + ',height=' + screen.availHeight);
            }//from  w w w . j  a va 2 s . co  m
            function closeFunction() {
              window.close()
            }
        
      </script>  
   </body>
</html>

Related Tutorials