onpageshow event
Examples
JavaScript is triggered when users browse the web:
try it"
Bottom of this article contains more examples.
Definition and Usage
onpageshow event is triggered when users browse the web.
onpageshow events similar to the onload event, onload event fires when the page first loads, onpageshow event triggered each time the page is loaded, the onload event does not fire when the page is read from the browser cache.
In order to view the page is loaded directly from the server or read from the cache, you can use the property PageTransitionEvent persisted objects to judge. If a page is read from the browser's cache, this property returns ture, otherwise it returns false (see the following "more examples").
Browser Support
Figures in the table represent the first browser to support this version of events.
event | |||||
---|---|---|---|---|---|
onpageshow | Yes | 11.0 | Yes | 5.0 | Yes |
grammar
In HTML:
In JavaScript:
JavaScript, use the addEventListener () method:
NOTE: Internet Explorer8 and earlier versions of IE browser does not support addEventListener () method.
technical details
Whether to support the bubble: | No |
---|---|
It can be canceled: | No |
Event Type: | PageTransitionEvent |
Supported HTML tags: | <Body> |
More examples
Examples
Check whether the page is read from the browser cache:
alert ( "This page is read from the browser cache?" + event.persisted);
}
try it"
Event objects