Last active
December 17, 2015 04:29
-
-
Save lrowe/5551102 to your computer and use it in GitHub Desktop.
Problem with pushState and back button in Safari/Chrome.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Cache-Control" content="no-cache, no-store" /> | |
<script> | |
function navigate() { | |
var missing_url = window.location.pathname + '/missing' | |
window.history.pushState({test:'test'}, 'new page', missing_url); | |
// Reloading will return the 404 | |
window.location.reload(); | |
} | |
</script> | |
</head> | |
<body> | |
<p>Click the button to navigate to a missing page with pushSate and reload.</p> | |
<button onclick="navigate()">Navigate</button> | |
<p>Subsequently clicking back does not reload this page on Chrome or Safari but leaves you on the 'missing' 404 page. With Firefox you are returned to this page.</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running at http://bl.ocks.org/lrowe/raw/5551102/2c81271083e26b9333c578e3f579eb304daf478d/