Reputation: 63
I have project in which I have an elements from other domains. I'm using JavaScript to access first iframe window object into variable. Here is code :
var iframes = window.frames;
//grab first iframe
var ifrWindow = iframes[0].window; // Here is where I get **Permision denied**
ifrWindow.postMessage("hello",IframeDomain);
I'm getting 'Permission denied' only for IE8. I have no problems with Chrome, Firefox, Safari or later versions IE11, etc..
Anyone has experienced this kind of issue with IE8?
Upvotes: 6
Views: 13942
Reputation: 1932
Have you tried contentWindow or contentDocument method?
Something like this should work:
var iframe = document.getElementById("myframe");
var iframeWindow = (iframe.contentWindow || iframe.contentDocument);
Upvotes: 8