-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
29 lines (27 loc) · 887 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!doctype html>
<html>
<head><title>URL Routing in Pure JS</title></head>
<body>
<h1 id='caption'></h1>
<a href="">Home</a><hr>
<a href="#js">JavaScript</a><a href="#python">Python</a><a href="#php">PHP</a><a href="#java">Java</a><hr>
<a href="#angular">Angular</a><a href="#vuejs">Vue.js</a><a href="#ember">Ember</a><a href="#react">React</a>
<script>
function displayHash() {
var theHash = window.location.hash;
if (theHash.length == 0) { theHash = "_index"; }
var elems = document.querySelectorAll("#caption");
elems[0].innerText = "Current Hash: " + theHash;
return true;
}
window.addEventListener("hashchange", function() {
console.log("hashchange event");
displayHash();
});
window.addEventListener("DOMContentLoaded", function(ev) {
console.log("DOMContentLoaded event");
displayHash();
});
</script>
</body>
</html>