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
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
24 Aug, 2022
Like Article
Save Article