How to access the parent page elements of an Iframe
How to access the paren开发者_JAVA技巧t page elements of an Iframe. e.g. If i have a page index.htm and another page in an IFrame in index.htm and want to access the elements of index.htm from that IFrame.
javascript:
parent.document.getElementById('myElement');
jquery:
$('#myElement', window.parent.document);
See my reply to a similar question here:
move input text from iframe to main window
basically, parent gives you the "window" object of the parent window. You can then access window.document to get document... and therefore, you can get window.document.getElementById() by using parent.document.getElementById(id);
精彩评论