From 4105be9bd22e0fe71ae2148a9b045afb39b60a76 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sun, 7 Aug 2022 16:15:49 +0400 Subject: [PATCH] Improved browsing history tracking & traversal Before this fix, browsing history didn't work at all. Now it mostly works but there are still some quirks that must be debugged further. Since session history handling turns out to be a rather complex topic (see https://html.spec.whatwg.org/multipage/history.html) the work in that direction will be postponed until other features reach a comparable level of readiness. --- static/viewer.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/static/viewer.html b/static/viewer.html index ca059e684..b72167f27 100644 --- a/static/viewer.html +++ b/static/viewer.html @@ -42,7 +42,7 @@ const iframeContentUrl = userUrl2IframeUrl(hash.slice(1)); console.log("handle_location_hash_change: " + hash); if ( iframeContentUrl != cf.contentWindow.location.pathname ) { - cf.src = iframeContentUrl; + cf.contentWindow.location.replace(iframeContentUrl); } } @@ -53,7 +53,9 @@ document.title = cf.contentDocument.title; const iframeContentUrl = cf.contentWindow.location.pathname; console.log('handle_content_url_change: ' + iframeContentUrl); - window.location.hash = iframeUrl2UserUrl(iframeContentUrl); + const newHash = '#' + iframeUrl2UserUrl(iframeContentUrl); + const viewerURL = location.origin + location.pathname + location.search; + window.location.replace(viewerURL + newHash); };