I have an iframe which will be inserted dynamically into the parent page (I don’t have control over this domain) using following script…
var _hf_iFrame = document.createElement("iframe");
_hf_iFrame.setAttribute("id", "_hf_iFrame");
_hf_iFrame.setAttribute("name", "_hf_iFrame");
_hf_iFrame.setAttribute("style", "height: 354px; width: 445px; border: 0; margin-left: -400px; top: 23%; position: fixed;");
document.body.appendChild(_hf_iFrame);
_hf_iFrame.setAttribute("src", "http://anotherdomain.com/frame.html");
I want to change the css properties of the iframe from iframe itself.
Is it possible to achieve this? I am using JQuery inside my iframe.
Thanks in advance.
You can’t do this.
You have two documents. The parent and the framed. The iframe element exists within the parent, so to modify it you need to modify the parent document.
Your code runs in the framed document, which is on a different domain, so the same origin policy prevents you from reaching the parent document to modify it.