Find out whether the page was cached by the browser: - Javascript DOM Event

Javascript examples for DOM Event:onpageshow

Description

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)">

<h1>Hello World!</h1>

<script>
function myFunction(event) {/*from  w ww.j  a v a 2 s .c om*/
    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