Thursday, 15 July 2010

javascript - Executing a function on initial page load (and user refreshes) but not back button -


I would like to perform a JavaScript (or jQuery) initialization function - let's call it myPageInit () After the page is completely full.

Cache is here : myPageInit () should run only The page is initially loaded or if the user Forcing one page to refresh (i.e. the browser reload button presses, hits F5 , etc.).

To avoid suspicion:

  • should not no run. User navigates to www.mypage.com = & gt; myPageInit () page runs after loading.
  • User can now refresh the browser button = & gt; runs myPageInit () after reloading the page.
  • The user now clicks on a link on the page (like & lt; a href = "www.cnn.com" & gt; ... ).
  • The user clicks the back button to go back to www.mypage.com = & gt; myPageInit () runs after the No page.

    which I have tried so far

    • $ ( window). Load () - I think it used to work, but it appears on modern browsers when the user presses the back button (see note on the comment)

    • $ (window) .ready () - It also shows the fire on both the initial load and the back button.

    • Searching for other relevant answers. I still could not find what I'm looking for.

      Thanks in advance!

      Maybe you do not want to do exactly that, but about a session cookie or HTML storage flag How in See code and answers here:

      For example

No comments:

Post a Comment