views:

116

answers:

2

How to access the parent 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.

+1  A: 

javascript:

parent.document.getElementById('myElement');

jquery:

$('#myElement', window.parent.document);
chrissr
A: 

See my reply to a similar question here:
http://stackoverflow.com/questions/2304076/move-input-text-from-iframe-to-main-window/2304138#2304138

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

ItzWarty