diff options
author | Thedro Neely <thedroneely@gmail.com> | 2022-04-03 02:23:50 -0400 |
---|---|---|
committer | Thedro Neely <thedroneely@gmail.com> | 2022-04-03 02:23:50 -0400 |
commit | 218a42551c4e7a03b0c76bf70843934674ccfd3f (patch) | |
tree | 07dcf5ea97718e872e02ecdfc8d6b7b71c654a26 /public/js/app.js | |
parent | 58b4eb4226c2ca44c7aa50c771b34e3bef6ae7a1 (diff) | |
download | thedroneely.com-218a42551c4e7a03b0c76bf70843934674ccfd3f.tar.gz thedroneely.com-218a42551c4e7a03b0c76bf70843934674ccfd3f.tar.bz2 thedroneely.com-218a42551c4e7a03b0c76bf70843934674ccfd3f.zip |
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.
Diffstat (limited to 'public/js/app.js')
-rw-r--r-- | public/js/app.js | 3 |
1 files changed, 2 insertions, 1 deletions
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; } |