More "Try it Yourself" examples below.
Definition and Usage
The onpageshow event occurs when a user navigates to a webpage.
The onpageshow event is similar to the onload event, except that it occurs after the onload event when the page first loads. Also, the onpageshow event occurs every time the page is loaded, whereas the onload event does not occur when the page is loaded from the cache.
To find out if a page is loaded directly from the server or if the page is cached, you can use the persisted property of the PageTransitionEvent object. This property returns true if the page is cached by the browser, and false otherwise (see "More Examples" below).
The numbers in the table specify the first browser version that fully supports the event.
Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.
|Supported HTML tags:||<body>|
|DOM Version:||Level 3 Events|
Find out whether the page was cached by the browser: