diff --git a/src/main/web/js/persistent-toc.js b/src/main/web/js/persistent-toc.js index 9cf2ee10d..5b1badf7e 100644 --- a/src/main/web/js/persistent-toc.js +++ b/src/main/web/js/persistent-toc.js @@ -134,12 +134,26 @@ + window.location.hash); } - let path = window.location.pathname.substring(1) + window.location.hash; + // Try path#hash + let path = url.substring(1) + hash; let target = document.querySelector("nav.toc div a[rel-path='"+path+"']"); if (target) { target.scrollIntoView(); } else { - console.log(`ToC scroll, no match: ${path}`); + // Try #hash + target = document.querySelector("nav.toc div a[rel-path='"+hash+"']"); + if (target) { + target.scrollIntoView(); + } else { + // Try path + target = document.querySelector("nav.toc div a[rel-path='"+url.substring(1)+"']"); + if (target) { + target.scrollIntoView(); + } else { + // ??? + console.log(`ToC scroll, no match: ${path}`); + } + } } if (!searchListener) {