Execute a script when a user navigates to a page in HTML?

HTMLWeb DevelopmentFront End Technology

Use the onpageshow attribute to execute a script when a user navigates to a page.

Example

You can try to run the following code to implement onpageshow attribute −

<!DOCTYPE html>
<html>
   <body onpageshow = "display()">
      <h2>Tutorialspoint</h2>
      <p>Simply Easy Learning</p>
      <script>
         function display() {
            alert(You're back!");
         }
      </script>
   </body>
</html>
raja
Published on 14-Mar-2018 10:57:07
Advertisements