summaryrefslogtreecommitdiff
path: root/elm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-08-06 14:03:08 +0200
committerYorhel <git@yorhel.nl>2020-08-06 14:03:10 +0200
commit4ff57327c4c95652c0634ca97ed5495c037fc16e (patch)
tree2523f24f46f02c7ed038ca9c36bec020a4cb9acd /elm
parent7004c6deffd56b88df93a15ebf75ec593443aa4b (diff)
Discussions: Fix emulation of location.hash
Setting location.hash directly has the downside of adding an entry to the browser's history, which is annoying.
Diffstat (limited to 'elm')
-rw-r--r--elm/sethash.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/elm/sethash.js b/elm/sethash.js
index 3441a650..7b054d0b 100644
--- a/elm/sethash.js
+++ b/elm/sethash.js
@@ -1,2 +1,8 @@
-if(pageVars.sethash && location.hash.length <= 1)
- location.hash = pageVars.sethash;
+// Emulate setting a location.hash if none has been set.
+if(pageVars.sethash && location.hash.length <= 1) {
+ var e = document.getElementById(pageVars.sethash);
+ if(e) {
+ e.scrollIntoView();
+ e.classList.add('target');
+ }
+}