Javascript DOM onpageshow Event via addEventListener() method

Introduction

In JavaScript, using the addEventListener() method:

object.addEventListener("pageshow",
       myScript);

This example uses the addEventListener() method to attach a "pageshow" event to the window object.

View in separate window

<!DOCTYPE html>
<html>
<body>
<h1 id="demo"></h1>

<script>
window.addEventListener("pageshow", myFunction);

function myFunction() {/*from   w  w  w.j a va 2s. c  o m*/
  document.getElementById("demo").innerHTML = "Welcome To My Homepage!";
}
</script>

</body>
</html>
Bubbles: No
Cancelable: No
Event type: PageTransitionEvent
Supported HTML tags: <body>



PreviousNext

Related