I have a mostly blank HTML page, that links to an iframe. The iframe page contains some text and 2 buttons tied to onclick scripts. I want to click the buttons, but I'm not able to get the values of getboundingclientrect when I supply the ID. How can I get the value of getboundingclientrect for an element (button) inside the iframe page in IE9?
Thanks for looking.
EDIT: made question more specific
Like this, if it is the same domain. If it is a different domain, it won't work.
var myIFrame = document.getElementById('iframename');
var content = myIFrame.contentWindow.document.body.innerHTML;
A different domain would be:
Parent: www.test.com
Child: sub.test.com
or Child: www.testpage.com
It has to do with the same origin policy
As long as you're not doing something with a cross domain scenario this will work cross browser.
function getIFrameDoc(frame) {
return frame.contentWindow ? frame.contentWindow.document : frame.contentDocument ? frame.contentDocument : frame.document;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.