This repository has been archived on 2024-05-11. You can view files and clone it, but cannot push or open issues or pull requests.
meshviewer/html/embed.js

25 lines
805 B
JavaScript

(function() {
var iframe=document.getElementById("meshviewer-embedded")
if (!iframe) {
console.log("IFrame 'meshviewer-embedded' not found")
return;
}
if (!iframe.contentWindow) {
console.log("Element 'meshviewer-embedded' seems not to be a valid iframe")
return;
}
if (document.location.hash) {
window.setTimeout(function() {
iframe.contentWindow.location.hash = document.location.hash;
}, 0);
}
iframe.contentWindow.addEventListener("message", (event) => {
if (event && event.data && event.data.hash) {
window.location.hash = event.data.hash;
}
}, false);
window.onhashchange = function () {
iframe.contentWindow.location.hash = document.location.hash;
};
}) ();