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?
If the content of the iframe and its parent have the same domain, you can access the parent pages DOM from the iframe by using parent. document.
The contentWindow property returns the Window object of an HTMLIFrameElement. You can use this Window object to access the iframe's document and its internal DOM. This attribute is read-only, but its properties can be manipulated like the global Window object.
The window will get opened by using the iframe, and the communication could be done with the parent window from the child window. To call a parent window function, use the following syntax and also refer to the code given below.
Have you tried contentWindow or contentDocument method?
Something like this should work:
var iframe = document.getElementById("myframe");
var iframeWindow = (iframe.contentWindow || iframe.contentDocument);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With