Edit This Code:
<!DOCTYPE html>
<html>
<body>

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

<p><strong>Note:</strong> The onpageshow event is not supported in Internet Explorer 10 and earlier versions.</p>

<h1 id="demo"></h1>

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

function myFunction() {
  document.getElementById("demo").innerHTML = "Welcome To My Homepage!";
};

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

</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy