Jump to content

load vs pageshow event when page is cached


davej

Recommended Posts

So the load event cannot reliably be used to initialize a page? That seems strange to me.

 

I've never noticed this problem but I guess it occurs more on smartphones?

 

http://www.w3schools.com/jsref/event_onpageshow.asp

 

http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onpageshow_persisted

 

http://lucentminds.com/archives/using-pageshow-to-detect-cached-pages.html

Link to comment
Share on other sites

It seems that some browsers don't load the page again when you press the back button, they just show the cached version they had. The load event fires when an HTTP transaction has completed. If the data is coming from the cache there is no HTTP transaction.

Link to comment
Share on other sites

I just attempted to get the "tryitnow" example to give me a "true" on my iPhone but it kept giving me "false" until the phone went to sleep and then woke up. Then it gave me the 'true."

 

At first glance the onload event also seems to be triggered -- since onload styling or results remain visible -- but these are only cached results.

 

I have a little test page here...

 

http://www.stlnetwork.net/test/mobiletest.html

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...