Created
March 30, 2017 19:50
-
-
Save mikaxyz/ea0a78247e2acc457146c0d1b5f3057b to your computer and use it in GitHub Desktop.
Hashchange/click event problem in Chrome Mac
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 lang="en"> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Hashchange</title> | |
</head> | |
<body> | |
<a id="bck">Back</a> - | |
<a id="fwd">Forward</a> | |
<script> | |
var page = parseInt(location.hash.replace('#/', ''), 10) || 0; | |
function renderPagination() { | |
document.getElementById("bck").href = "/#/" + (page - 1); | |
document.getElementById("fwd").href = "/#/" + (page + 1); | |
document.getElementById("bck").innerText = "Back to " + (page -1); | |
document.getElementById("fwd").innerText = "Forward to " + (page + 1); | |
} | |
renderPagination(); | |
window.onhashchange = function(event) { | |
page = parseInt(location.hash.replace('#/', ''), 10) || 0; | |
renderPagination(); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment