Skip to content

Instantly share code, notes, and snippets.

@jdmansour
Created May 14, 2013 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdmansour/5578079 to your computer and use it in GitHub Desktop.
Save jdmansour/5578079 to your computer and use it in GitHub Desktop.
Test if the browser caches the current state of the document, or just the initial state. Open test.html, wait a few seconds, and click on the link. Then click the back button. The counter should be at the value it had when you left the page.
<html>
<head>
<script>
function tick() {
var dyn = document.getElementById("dyn");
var value = parseInt(dyn.innerHTML);
dyn.innerHTML = value + 1;
}
window.setInterval(tick, 1000);
</script>
</head>
<body>
<h1>Page 1</h2>
<p><a href="http://www.google.com">Go to Google.com</a></p>
<p>Seconds elapsed: <span id="dyn">0</span></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment