Handling of manual hash component change

This commit is contained in:
Veloman Yunkan 2022-03-19 15:54:26 +04:00
parent 4db443eca6
commit e5f97d95b1
1 changed files with 12 additions and 1 deletions

View File

@ -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;