Open popup before closing the current tab - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window open

Description

Open popup before closing the current tab

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*  ww w  .  j  a v  a2s.  c om*/
     var popWindow = true;
     window.onbeforeunload = function() {
          if(popWindow == true) {
               popWindow = false;
               return "Sure?";
          }
     }
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials