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: 2020-05-21T07:46:57+05:30

208 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements