HTML onpageshow Event Attribute

Description

The event attribute onpageshow is triggered when a user navigates to a web page.

The onpageshow event is much like the onload event. The difference is that this event occurs after the onload event, when the page is loaded for the first time. Also, the onpageshow event occurs whenever the page loads, while the onload event does not occur if the page is loaded from the cache.

Syntax

<element onpageshow="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE HTML>
<html>

<body onpageshow="myFunction()">
<h1>Onpageshow Event!</h1>
<p>Reload the page to see the vent trigger again!</p>
<script>
function myFunction() {
    alert("Welcome!");
}
</script>

</body>
</html>

Supported Tags

<body>

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
??????
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
??????