diff --git a/html/embed.html b/html/embed.html
index a0113c3..26b32b8 100644
--- a/html/embed.html
+++ b/html/embed.html
@@ -1,6 +1,6 @@
-
+
diff --git a/html/embed.js b/html/embed.js
index 32c5b0e..1a9b05e 100644
--- a/html/embed.js
+++ b/html/embed.js
@@ -11,22 +11,17 @@
}
function updateIframeHash() { // see https://gist.github.com/manufitoussi/7529fa882ff0b737f257
- if(iframe.contentWindow.location.host !== "") {
- // iframe already loaded.
- iframe.contentWindow.location.hash = window.location.hash;
- } else {
- // iframe is just starting.
- var newHash = window.location.hash;
- var srcStr = iframe.getAttribute('src');
- var words = srcStr.split('#');
- var href = words[0];
- var newSrc = href + newHash;
- iframe.setAttribute('src', newSrc);
- }
+ // iframe is just starting.
+ var newHash = window.location.hash;
+ var srcStr = iframe.getAttribute('src');
+ var words = srcStr.split('#');
+ var href = words[0];
+ var newSrc = href + newHash;
+ iframe.setAttribute('src', newSrc);
};
updateIframeHash();
- iframe.contentWindow.addEventListener("message", (event) => {
+ window.addEventListener("message", (event) => {
if (event && event.data && event.data.hash) {
window.location.replace(event.data.hash);
}
diff --git a/lib/main.js b/lib/main.js
index 9421e5d..9add864 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -72,7 +72,7 @@ define(['moment', 'utils/router', 'leaflet', 'gui', 'helper', 'utils/language'],
}
window.onhashchange = function () {
- window.postMessage({hash: window.location.hash}, '*');
+ parent.postMessage({hash: window.location.hash}, '*');
};
var language = new Language();