PageTransitionEvent persisted Property - Javascript DOM

Javascript examples for DOM:PageTransitionEvent

Description

The persisted property tells if the webpage is loaded directly from the server, or if the page is cached.

This property is read-only.

Return Value

A Boolean, telling if the webpage is loading from a cache.

  • Possible values: true - The page is cached by the browser
  • false - The page is NOT cached by the browser

The following code shows how to find out whether the page was cached by the browser:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body onpageshow="myFunction(event)">

<script>
function myFunction(event) {/*  w  ww  .j a  v a 2 s  . c  o  m*/
    if (event.persisted) {
        console.log("The page was cached by the browser");
    } else {
        console.log("The page was NOT cached by the browser");
    }
}
</script>

</body>
</html>

Related Tutorials