Created
January 29, 2016 13:12
-
-
Save AndyNovo/a76d14271aadbca82618 to your computer and use it in GitHub Desktop.
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="content-type" content="text/html; charset=utf-8" /> | |
<title>Sample SPA using HashChange</title> | |
<script type="text/javascript" charset="utf-8"> | |
var handleHash = function(){ | |
alert("Hash changed to "+location.hash); | |
document.body.innerHTML = document.querySelector(location.hash).innerHTML; | |
}; | |
window.addEventListener("hashchange", handleHash); | |
</script> | |
<script type="html/template" id="p1"> | |
Page 1 | |
<a href="#p2">Alter it again</a> | |
</script> | |
<script type="html/template" id="p2"> | |
Page 2 | |
<a href="#p3">Alter it again</a> | |
</script> | |
<script type="html/template" id="p3"> | |
Page 3 | |
<a href="#p1">Alter it again</a> | |
</script> | |
</head> | |
<body> | |
<p> | |
Ahhh. No page loaded!!!??!?!?! | |
</p> | |
<a href="#p1">Click here to alter the hash</a> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment