Site: a reload no longer jumps back to the download section
After a jump to an anchor (a download badge, a menu link) the anchor is dropped from the address, so a reload keeps the place the visitor scrolled to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a773d73208
commit
7b0cd27507
1 changed files with 11 additions and 6 deletions
|
|
@ -216,12 +216,17 @@
|
|||
}
|
||||
function openHash() {
|
||||
var id = location.hash.slice(1);
|
||||
if (!id || id.indexOf("download-") !== 0) return;
|
||||
var panelId = id.replace(/^(download-(windows|macos|linux)).*/, "$1");
|
||||
var tab = tabs.filter(function (x) { return x.getAttribute("aria-controls") === panelId; })[0];
|
||||
if (tab) select(tab);
|
||||
var target = $(id);
|
||||
if (target) target.scrollIntoView();
|
||||
if (!id || /^screenshot-/.test(id)) return;
|
||||
if (id.indexOf("download-") === 0) {
|
||||
var panelId = id.replace(/^(download-(windows|macos|linux)).*/, "$1");
|
||||
var tab = tabs.filter(function (x) { return x.getAttribute("aria-controls") === panelId; })[0];
|
||||
if (tab) select(tab);
|
||||
var target = $(id);
|
||||
if (target) target.scrollIntoView();
|
||||
}
|
||||
// The jump is done: drop the anchor, or a reload jumps there again from wherever
|
||||
// the visitor has scrolled since.
|
||||
history.replaceState(history.state, "", location.pathname + location.search);
|
||||
}
|
||||
window.addEventListener("hashchange", openHash);
|
||||
openHash();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue