html tutorial - onpageshow Attribute in HTML - html5 - html code - html form



  • The onpageshow attribute occurs when a user redirect to a webpage.
  • The onpageshow attribute is related to the onload attribute.
  • The onload attribute happens when the page loads first.
  • The onpageshow attribute happens every time the page is loaded, whereas the onload event does not happens though the page is loaded from the cache.
  • The onpageshow attribute is the part of the Event Attributes.

Syntax for onpageshow attribute in HTML:

<body onpageshow="script">

Applies To:

Element Attribute
<body> onpageshow

Attribute Values:

Value Description
script The script can run on onpageshow

Sample Coding for onpageshow Attribute in HTML:

Tryit<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy onpageshow attribute</title>
    </head>
    <body onpageshow="onPageShow()">
    <h1>Wikitechy HTML onpageshow Attribute </h1>
    <script>
     function onPageShow() 
     {
        alert("Welcome To Wikitechy!");
     }
    </body>
</html>

Code Explanation for onpageshow Attribute in HTML:

onpageshow Attribute Code Explanation

  1. The onpageshow attribute calls the JavaScript Function onPageShow() and occurs when a user navigates the page every time.
  2. The JavaScript Function onPageShow() executes the alert dialogue box with the message ” Welcome to Wikitechy!”.

Output for onpageshow Attribute in HTML:

onpageshow Attribute Tag Output

  1. On webpage loading, the alert box will be displayed with the message ” Welcome to Wikitechy!”

Browser Support for onpageshow Attribute in HTML:

Yes 11.0 Yes 5.0 Yes

Related Searches to onpageshow attribute in html