Advertisement
badlogic

load the page one time

Jul 28th, 2016
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. <script type='text/javascript'>
  2.  
  3.     (function()
  4.     {
  5.         if( window.localStorage )
  6.         {
  7.             if( !localStorage.getItem( 'firstLoad' ) )
  8.             {
  9.                 localStorage[ 'firstLoad' ] = true;
  10.                 window.location.reload();
  11.             }
  12.             else
  13.                 localStorage.removeItem( 'firstLoad' );
  14.         }
  15.     })();
  16.  
  17. </script>
  18.  
  19. <script type="text/javascript">
  20.     ;(function () {
  21.         var reloads = [2000, 13000],
  22.             storageKey = 'reloadIndex',
  23.             reloadIndex = parseInt(localStorage.getItem(storageKey), 10) || 0;
  24.  
  25.         if (reloadIndex >= reloads.length || isNaN(reloadIndex)) {
  26.             localStorage.removeItem(storageKey);
  27.             return;
  28.         }
  29.  
  30.         setTimeout(function(){
  31.             window.location.reload();
  32.         }, reloads[reloadIndex]);
  33.  
  34.         localStorage.setItem(storageKey, parseInt(reloadIndex, 10) + 1);
  35.     }());
  36. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement