Open In App

HTML | DOM PageTransitionEvent

Last Updated : 24 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The PageTrasitionEvent occurs during the time a document is being loaded or unloaded. 

Syntax:

PageTransitionEvent.persisted

Property Values:

  • persisted: Returns boolean value whether the webpage was cached or not.

Return Value: This property returns True if the document is loaded from a cache or not otherwise it returns False. Example: 

html




<!DOCTYPE html>
<html>
 
<body bgcolor="green" onpageshow="myFunction(event)">
    <center>
        <h1 style="color:white;">GeeksforGeeks</h1>
        <p id="demo" style="color:white;"></p>
    </center>
    <script>
        function myFunction(event) {
           
            // Check page was cached by the browser
            // or not.
            if (event.persisted) {
                alert("Cached by Browser");
            } else {
                alert("NOT cached by Browser");
            }
        }
    </script>
</body>
 
</html>


Output:

  

Supported Browsers:

  • Google Chrome 4
  • Firefox 11
  • Edge 12
  • Safari 5
  • Opera 15

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads