Horje
HTML onpageshow Event Attribute

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.



Example of HTML onpageshow Event Attribute

Here Executes a JavaScript when a user navigates to a webpage.
index.html
Example: HTML
 <body onpageshow="myFunction()"> 

Output should be:

Example of HTML onpageshow Event Attribute

Browser Support of HTML onpageshow Event Attribute

The numbers in the table specify the first browser version that fully supports the event attribute.

Browser Support of HTML onpageshow Event Attribute

Syntax of HTML onpageshow Event Attribute

<element onpageshow="script">

Attribute Values of HTML onpageshow Event Attribute

Value Description
script The script to be run on onpageshow

Technical Details of HTML onpageshow Event Attribute

Supported HTML tags: <body>

How to add a JavaScript when a user navigates to a webpage

See the code.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body onpageshow="myFunction()">

<h1>Hello World!</h1>

<script>
function myFunction() {
  alert("Welcome!");
}
</script>

</body>
</html>

Output should be:

How to add a JavaScript when a user navigates to a webpage




html event attributes

Related Articles
HTML onafterprint Event Attribute Window Event Attributes
HTML onbeforeprint Event Attribute Window Event Attributes
HTML onbeforeunload Event Attribute Window Event Attributes
HTML onerror Event Attribute Window Event Attributes
HTML onhashchange Event Attribute Window Event Attributes
HTML onload Event Attribute Window Event Attributes
HTML onoffline Event Attribute Window Event Attributes
HTML ononline Event Attribute Window Event Attributes
HTML onpageshow Event Attribute Window Event Attributes
HTML onresize Event Attribute Window Event Attributes
HTML onunload Event Attribute Window Event Attributes

Single Articles
Example of HTML onpageshow Event AttributeWindow Event Attributes
Browser Support of HTML onpageshow Event AttributeWindow Event Attributes
Syntax of HTML onpageshow Event AttributeWindow Event Attributes
Attribute Values of HTML onpageshow Event AttributeWindow Event Attributes
Technical Details of HTML onpageshow Event AttributeWindow Event Attributes
How to add a JavaScript when a user navigates to a webpageWindow Event Attributes

Type:
Develop
Category:
Web Tutorial
Sub Category:
Window Event Attributes
Uploaded by:
Admin


Reffered: https://www.w3schools.com/tags/ev_onpageshow.asp