fix: weiße Seite bei Zurück-Navigation (bfcache) + Dock-Active-Match auf Pfadsegment
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1efd81846d
commit
40fccf2eeb
1 file changed
+15
-5
@@ -66,6 +66,12 @@
|
|||||||
setTimeout(function () { window.location.href = ziel; }, 320);
|
setTimeout(function () { window.location.href = ziel; }, 320);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Zurück-Navigation: der Back-Forward-Cache stellt die Seite im
|
||||||
|
ausgeblendeten Zustand (seite-ausgang) wieder her → wieder einblenden */
|
||||||
|
window.addEventListener("pageshow", function (e) {
|
||||||
|
if (e.persisted) document.body.classList.remove("seite-ausgang");
|
||||||
|
});
|
||||||
|
|
||||||
/* ---------- 3) Scroll-Einblenden ---------- */
|
/* ---------- 3) Scroll-Einblenden ---------- */
|
||||||
var elemente = document.querySelectorAll(".einblenden");
|
var elemente = document.querySelectorAll(".einblenden");
|
||||||
if (elemente.length && "IntersectionObserver" in window && !reduce) {
|
if (elemente.length && "IntersectionObserver" in window && !reduce) {
|
||||||
@@ -83,14 +89,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- 4a) Dock-Active-State ---------- */
|
/* ---------- 4a) Dock-Active-State ---------- */
|
||||||
/* decodeURIComponent: Umlaut-URLs (über-mich) kommen prozent-kodiert an */
|
/* decodeURIComponent: Umlaut-URLs (über-mich) kommen prozent-kodiert an.
|
||||||
var pfad = decodeURIComponent(window.location.pathname).replace(/\/index\.html$/, "/");
|
Vergleich nur über das letzte Pfadsegment – ein Teilstring-Vergleich
|
||||||
|
würde z. B. am GitLab-Projektpfad /portfolio-photo/ fälschlich matchen. */
|
||||||
|
var pfad = decodeURIComponent(window.location.pathname);
|
||||||
|
var seite = pfad.replace(/\/$/, "").split("/").pop()
|
||||||
|
.replace(/\.html$/, "").replace(/^index$/, "");
|
||||||
var dockLinks = document.querySelectorAll(".dock-links a");
|
var dockLinks = document.querySelectorAll(".dock-links a");
|
||||||
dockLinks.forEach(function (a) {
|
dockLinks.forEach(function (a) {
|
||||||
var hp = a.getAttribute("href") || "";
|
var hp = a.getAttribute("href") || "";
|
||||||
var norm = hp.replace(/^\.\//, "/").replace(/\/$/, "");
|
if (/^(mailto:|tel:|https?:|#)/i.test(hp)) return;
|
||||||
var aktuell = pfad.replace(/\/$/, "");
|
var ziel = hp.replace(/\/$/, "").split("/").pop().replace(/\.html$/, "");
|
||||||
if (norm && aktuell.indexOf(norm) !== -1 && norm !== "/") {
|
if (ziel && seite === ziel) {
|
||||||
a.setAttribute("aria-current", "page");
|
a.setAttribute("aria-current", "page");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user