Last active
February 17, 2016 18:04
-
-
Save zapthedingbat/1ff548931e3b81063c32 to your computer and use it in GitHub Desktop.
Chrome Unload Back Bug
This file contains 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> | |
<script> | |
window.addEventListener('unload', function(){ | |
var origionalUrl = location.href; | |
var newUrl = origionalUrl.replace('#.*$', '') + '#nope'; | |
console.log('cancel navigation', newUrl); | |
window.location.replace(newUrl); | |
window.location.replace(origionalUrl); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>Back Bug</h1> | |
<p> | |
Click back to leave this page. | |
</p> | |
<p> | |
<a href="http://www.example.com">Somewhere Else</a> | |
</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment