Javascript DOM onpageshow Event via HTML Tag onpageshow function

Introduction

In JavaScript:

object.onpageshow = function(){
       myScript};

This example uses the HTML DOM to assign an "onpageshow" event to a body element.

View in separate window

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

<script>
document.getElementsByTagName("BODY")[0].onpageshow = function() {myFunction()};

function myFunction() {/*w  ww.jav a  2s.  com*/
  document.getElementById("demo").innerHTML = "Welcome To My Homepage!";
};

/* equivalent to assigning the event to the window object
window.onpageshow = function() {
  document.getElementById("demo").innerHTML = "Welcome To My Homepage!";
};
*/
</script>

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



PreviousNext

Related