aboutsummaryrefslogtreecommitdiff
path: root/assets/js/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/index.js')
-rw-r--r--assets/js/index.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index 9f684bf..b284ce8 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -12,10 +12,13 @@
if (localStorage["settings"]) {
settings = JSON.parse(localStorage["settings"]);
}
- if (self.location.href.indexOf("#") >= 0) {
+ if (self.location.hash.length > 0) {
settings["pager"][url] = self.pageYOffset;
localStorage["settings"] = JSON.stringify(settings);
document.getElementById(location.hash.slice(1)).scrollIntoView();
+ self.addEventListener("load", function() {
+ document.getElementById(location.hash.slice(1)).scrollIntoView();
+ });
return;
}
if (settings["pager"][url] > 0) {
@@ -29,6 +32,9 @@
const currentPosition = self.pageYOffset;
settings["pager"][url] = currentPosition;
localStorage["settings"] = JSON.stringify(settings);
+ if (self.location.hash.length === 0) {
+ history.replaceState({}, document.title, window.location.href.split("#")[0]);
+ }
});
self.addEventListener("DOMContentLoaded", function() {
const up = document.getElementById("top");