开发者

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);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜