I've got a webpage that won't work properly if postMessage is not available. I'd like to use a simple:
if (window.postMessage === undefined) {
//alert the user
}
Are there any unforeseeable issues with this approach?
I've got a webpage that won't work properly if postMessage is not available. I'd like to use a simple:
if (window.postMessage === undefined) {
//alert the user
}
Are there any unforeseeable issues with this approach?
I'm not a JS expert, nor a fan, but heres my experience with a similar problem:
We had a similar problem: We use "postMessage" on an object to communicate with a native library loaded in the chrome browser. At some point, "postMessage" was undefined after it was working fine for communication.
It turns out it arose after we toggled the visibility of the div that contained the html object on which we were calling "postMessage" on.
We had something like:
In our case we were calling "postMessage" on the "embed" object (this is how communication with the native layer is being done).
So, if it is a similar scenario, maybe you have modified some properties of the "window" object which in turn made the "postMessage" function undefined. It's just a hint.
function handlingMsg(e){
var heightIn = (typeof e.data === "object") ? e.data['height'] : e.data;
$("#zbFrame").attr("height",Number(heightIn));
}
//iframe 적용
// <= ie8
if (!window.addEventListener) {
window.attachEvent("onmessage", handlingMsg);
}else{ // > ie8
window.addEventListener('message', handlingMsg, false);
}