hydrogen-web/prototypes/ie11-hashchange.html

25 lines
658 B
HTML
Raw Permalink Normal View History

2020-10-13 20:40:45 +05:30
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<ul id="changes"></ul>
<script type="text/javascript">
const ul = document.getElementById("changes");
window.onhashchange = function() {
const hash = document.location.hash.substr(1);
const li = document.createElement("li");
li.appendChild(document.createTextNode(hash));
ul.appendChild(li);
window.history.replaceState(null, null, "#" + hash + hash);
}
</script>
<p>
<a href="#foo">foo</a>
<a href="#bar">bar</a>
<a href="#baz">baz</a>
</p>
</body>
</html>