1. Please Sign Up if you don't have account. And Login if you have account.


Refresh once code js

Discussion in 'Webmaster Tutorials' started by meto20, Dec 13, 2017.

  1. meto20

    meto20 New Member SN Confirmed Member

    17
    23
    3
    In order to make a html page refresh automatically once/only one time, you should insert the following code:

    <script type='text/javascript'>

    (function()
    {
    if( window.localStorage )
    {
    if( !localStorage.getItem( 'firstLoad' ) )
    {
    localStorage[ 'firstLoad' ] = true;
    window.location.reload();
    }
    else
    localStorage.removeItem( 'firstLoad' );
    }
    })();

    </script>

    I hope it helps!
    Thanks!
     
    Fishy! likes this.
  2. Shirayukiie

    Shirayukiie New Member New Member

    8
    18
    3
    Sorry to ask, i'm quite the novice..
    But what are the use cases of this? I found this when looking a way to dynamically update content with js but cant really make it
     
    Fishy! likes this.
  3. highboi

    highboi New Member SN Confirmed Member

    5
    8
    3
    Reloading the page after the page loads is known to fix various issues when using older versions of IE
     
    Fishy! likes this.

Share This Page

Turning cookies on makes it easier for you to browse the web. Cookies are files created by websites you’ve visited, which store information, like the language you prefer or profile information. At Scriptznull, we use cookies to improve the quality of our service. Check our Privacy Policy for more information about cookies. Okay More information