HTML | DOM PageTransitionEvent

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:

Supported Browsers: