C
carlos
I am trying to access the content of my iframe src page. Something
like this:
document.getElementById('myFrame').contentWindow.document;
It works fine on a predifined iframe element, However, when creating
the iframe element
dynamically, and appending it to the body, I can't access the content
when doing this dynamic insertion. My guess would be that this is
because the iframe element doesn't yet exist on the Dom. See example
of problem below:
var myFrame = document.createElement("iframe");
myFrame.id = "testID";
myFrame.name = "testID";
myFrame.src = "testPage.htm";
myFrame.frameBorder = "0";
document.body.appendChild(myFrame);
//code below isn't working due to the above
document.getElementById('testID').contentWindow.document;
Does anyone have an example of what I can do to resolve this issue?
Thanks
like this:
document.getElementById('myFrame').contentWindow.document;
It works fine on a predifined iframe element, However, when creating
the iframe element
dynamically, and appending it to the body, I can't access the content
when doing this dynamic insertion. My guess would be that this is
because the iframe element doesn't yet exist on the Dom. See example
of problem below:
var myFrame = document.createElement("iframe");
myFrame.id = "testID";
myFrame.name = "testID";
myFrame.src = "testPage.htm";
myFrame.frameBorder = "0";
document.body.appendChild(myFrame);
//code below isn't working due to the above
document.getElementById('testID').contentWindow.document;
Does anyone have an example of what I can do to resolve this issue?
Thanks