From 218a42551c4e7a03b0c76bf70843934674ccfd3f Mon Sep 17 00:00:00 2001 From: Thedro Neely Date: Sun, 3 Apr 2022 02:23:50 -0400 Subject: public/js/app: Scroll to location hash Chrome does the opposite of Firefox on location hash refresh. https://superuser.com/questions/1471522/how-can-i-return-to-a-named-anchor-after-scrolling-in-chrome/1471549#1471549 Pass empty string on title in window.history.replaceState just to be safe. --- public/js/app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/js/app.js b/public/js/app.js index 3c6d91f..cbf5f07 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -14,7 +14,7 @@ function runOnce(action) { runOnce = function(){}; action(); } * Remove url query string */ var url = window.location.href.split('?')[0]; -window.history.replaceState(null, null, url); +window.history.replaceState(null, '', url); /** * Remove url hash to store in pager @@ -32,6 +32,7 @@ window.addEventListener('load', function(event) { if (window.location.href.indexOf("#") >= 0) { settings['pager'][url] = window.pageYOffset; localStorage['settings'] = JSON.stringify(settings); + document.getElementById(location.hash.slice(1)).scrollIntoView() return; } if (settings['pager'][url] > 0) { window.scrollTo(0, settings['pager'][url]); return; } -- cgit v1.2.3