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.
This commit is contained in:
Veloman Yunkan 2022-08-07 16:15:49 +04:00
parent e5f97d95b1
commit 4105be9bd2
1 changed files with 4 additions and 2 deletions

View File

@ -42,7 +42,7 @@
const iframeContentUrl = userUrl2IframeUrl(hash.slice(1)); const iframeContentUrl = userUrl2IframeUrl(hash.slice(1));
console.log("handle_location_hash_change: " + hash); console.log("handle_location_hash_change: " + hash);
if ( iframeContentUrl != cf.contentWindow.location.pathname ) { if ( iframeContentUrl != cf.contentWindow.location.pathname ) {
cf.src = iframeContentUrl; cf.contentWindow.location.replace(iframeContentUrl);
} }
} }
@ -53,7 +53,9 @@
document.title = cf.contentDocument.title; document.title = cf.contentDocument.title;
const iframeContentUrl = cf.contentWindow.location.pathname; const iframeContentUrl = cf.contentWindow.location.pathname;
console.log('handle_content_url_change: ' + iframeContentUrl); 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);
}; };
</script> </script>