From e5f97d95b1492f076c610c096b73bc57f479d693 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sat, 19 Mar 2022 15:54:26 +0400 Subject: [PATCH] Handling of manual hash component change --- static/viewer.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/static/viewer.html b/static/viewer.html index ea50fecfe..ca059e684 100644 --- a/static/viewer.html +++ b/static/viewer.html @@ -35,9 +35,20 @@ } const cf = document.getElementById('content_iframe'); - cf.src = userUrl2IframeUrl(window.location.hash.slice(1)); cf.height = window.visualViewport.height - cf.offsetTop - 4; + function handle_location_hash_change() { + const hash = window.location.hash; + const iframeContentUrl = userUrl2IframeUrl(hash.slice(1)); + console.log("handle_location_hash_change: " + hash); + if ( iframeContentUrl != cf.contentWindow.location.pathname ) { + cf.src = iframeContentUrl; + } + } + + window.onhashchange = handle_location_hash_change; + handle_location_hash_change(); + function handle_content_url_change() { document.title = cf.contentDocument.title; const iframeContentUrl = cf.contentWindow.location.pathname;