iFrame parent object? I' a bit lost.

G

gsb

I have an HTML page loaded into an iFrame contained in a DIV tag.
From the loaded document how would I reference the DIV object?

Thanks,

gsb
 
M

Martin Honnen

gsb said:
I have an HTML page loaded into an iFrame contained in a DIV tag.
From the loaded document how would I reference the DIV object?

You get the parent window with
parent
the document with
parent.document
and then you have the usual ways to access an element for instance
var div = parent.document.getElementById('divId');
so if the div has an id or you can set one then use that approach.
If you can't put an id on the div and you are really looking for a
generic solution to find the div container then post back, one would
need to loop through
parent.document.getElementsByTagName('iframe')
and compare name or location to find the relevant <iframe> element and
could then access the div as the parentNode
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top