Refresh (pressing F5) and get another page - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window localStorage

Introduction

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(){/* www  . ja  v a  2s.  com*/
(function(){
  var isPurchase2Loaded = localStorage.getItem("Purchase2");
  if(isPurchase2Loaded){
    document.write("Rerouting to purchase 1...");
  }
  else{
    document.write("Loading for the first Time...");
    localStorage.setItem("Purchase2", true);
  }
})()
    }

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

Related Tutorials