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 > |
Output:
Supported Browsers:
- Google Chrome
- Firefox
- Edge
- Safari
- Opera