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:
<!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
filter_none
Output:

Supported Browsers:
- Google Chrome
- Firefox
- Edge
- Safari
- Opera
Recommended Posts:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



