What is the usage of onpageshow event in JavaScript?


The onpageshow event triggers in JavaScript when a user reaches the new web page.

Example

You can try to run the following code to learn how to implement onpageshow event in JavaScript.

<!DOCTYPE html>
<html>
   <body onpageshow = "newFunc()">
      <p>On first visit, a welcome message is visible.</p>
      <script>
         function newFunc() {
            alert("Welcome!");
         }
      </script>
   </body>
</html>

Updated on: 21-May-2020

142 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements