limit one pop up per user, using JavaScript via localStorage - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window localStorage

Description

limit one pop up per user, using JavaScript via localStorage

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head> 
      <title>  michael coker</title> 
      <style>

body {/*from   w ww . j  a  va2  s.c o  m*/
   min-height: 100vh;
}
      </style> 
   </head> 
   <body translate="no"> 
      <script>
      document.body.onclick = function() {
  if (!localStorage.popup) {
    localStorage.popup = 1;
    window.open(
      "My site",
      "poppage",
      "toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=950, height=650, left = 300, top = 50"
    );
  }
};
    
      </script>  
   </body>
</html>

Related Tutorials