HTML onpageshow Event Attribute


The HTML onpageshow event attribute is triggered when a user navigates to a webpage.

Syntax

Following is the syntax −

<body onpageshow=”script”></body>

Let us see an example of HTML onpageshow event Attribute−

Example

 Live Demo

<!DOCTYPE html>
<html>
<style>
   body {
      color: #000;
      height: 100vh;
      background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat;
      text-align: center;
   }
</style>
<body onpageshow="showFn()">
<h1>HTML onpageshow Event Attribute Demo</h1>
<script>
   function showFn() {
      alert("Hey! you are on homepage");
   }
</script>
</body>
</html>

Output

Click on “ok” button of alert box to show the content of the HTML document.

Updated on: 27-Sep-2019

52 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements