Latest web development tutorials

onpageshow event

Event Object Reference Event objects

Examples

JavaScript is triggered when users browse the web:

<Body onpageshow = "myFunction ()">

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:

<Elementonpageshow = "myScript"> try

In JavaScript:

object .onpageshow = function () {myScript }; try

JavaScript, use the addEventListener () method:

object .addEventListener ( "pageshow", myScript ); try

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>


Examples

More examples

Examples

Check whether the page is read from the browser cache:

function myFunction (event) {
alert ( "This page is read from the browser cache?" + event.persisted);
}

try it"


Event Object Reference Event objects