Commit cf8b64e5 authored by Sven Franck's avatar Sven Franck

added simple postMessage example

parent 7812978f
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
$(document).ready(function () { $(document).ready(function () {
mapUrl(window.location); mapUrl(window.location);
window.top.postMessage({"type":"foo", "bar":"hello"}, window.location);
}); });
}(document, jQuery)); }(document, jQuery));
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
return null; return null;
}; };
var handler = function (event) {
console.log("hello inside handler");
console.log(event);
};
var mapUrl = function (url) { var mapUrl = function (url) {
var searchString = url.href.split("?")[1], var searchString = url.href.split("?")[1],
fileToDisplay; fileToDisplay;
...@@ -50,6 +55,12 @@ ...@@ -50,6 +55,12 @@
$(document).ready(function () { $(document).ready(function () {
mapUrl(window.location); mapUrl(window.location);
if (window.addEventListener){
window.addEventListener("message", handler, false)
} else {
window.attachEvent("onmessage", handler)
}
}); });
}(document, jQuery)); }(document, jQuery));
...@@ -10,11 +10,6 @@ ...@@ -10,11 +10,6 @@
(function (document, $) { (function (document, $) {
$(document).ready(function () { $(document).ready(function () {
localStorage.setItem("foo", JSON.stringify("bar"));
localStorage.setItem("bar", JSON.stringify("baz"));
sessionStorage.setItem("cous", JSON.stringify("cous"));
sessionStorage.setItem("deux", JSON.stringify("pommes"));
var mapUrl = function (url) { var mapUrl = function (url) {
var searchString = url.href.split("?")[1], var searchString = url.href.split("?")[1],
fileToDisplay; fileToDisplay;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment