iframe reading problems

J

Jeff Thies

I'm (still) having trouble reading the contents of an IFRAME (IE5).

I have this:
var my_iframe = document.frames['my_iframe'];

What I would want to do at that point is get either the
contentWindow.document or the contentDocument depending on whether this
was IE or Mozilla. (Thanks Lasse.)

I'm not finding this.

if I iterate through the properties:


var c='';
for (var prop in my_iframe){
c+='property:'+prop+"\n";
for(var item2 in my_frame.prop){
c+=' item2 '+item2;
}
}
alert(c);

I don't see the needed properties and none of the properties I do see
have any properties themselves.

Here are the properties I do see:

clientInformation,clipboardData,closed,defaultStatus,document,event
,external,frames,history,Image,length,location,name,navigator
,offscreenBuffering,onafterprint,onbeforeprint,onbeforeunload,onblur
,onerror,onfocus,onhelp,onload,onresize,onscroll,onunload,opener,Option
,parent,screen,screenLeft,screenTop,self,status,top,window

Is this an IE5.0 limitation (I use the "least common denominator"
browsers to test, and you can't load two IE versions on windows)?

Or have I done something else wrong?

Jeff
 
R

Richard Cornford

Jeff Thies said:
I'm (still) having trouble reading the contents of an IFRAME (IE5).

I have this:
var my_iframe = document.frames['my_iframe'];

What I would want to do at that point is get either the
contentWindow.document or the contentDocument depending
on whether this was IE or Mozilla. (Thanks Lasse.)

I'm not finding this.

if I iterate through the properties:
I don't see the needed properties and none of the
properties I do see have any properties themselves.

Here are the properties I do see:
Is this an IE5.0 limitation (I use the "least common denominator"
browsers to test, and you can't load two IE versions on windows)?

Or have I done something else wrong?

Assuming that the contents of the IFRAME do not originate in another
domain and so have not been rendered inaccessible by security
restrictions, there are two sides to an IFRAME. The IFRAME _element_ in
the DOM of the current page. You can get at that with
getElementsByTagName('iframe') and it may have one of the
'contentWindow' or 'contentDocument' (also look at its DOCUMENT,
Document & document properties on IE 5.0 but try the others first to
avoid confusion on Opera). The IFRAME is also represented as a normal
(usually; doesn't work like this on iceBrowser 5) frame in the
window.frames collection. The frame will have an index in the frames
collection, If it has an ID it may also appear as a named property of
the frames collection but the widest support for exposing an IFRAME as a
named property of the frames collection is to give the IFRAME element a
NAME attribute.

The object referenced by - document.frames['my_iframe']; - should be the
global object (window) for the page displayed within the IFRAME, so its
document property is the document within the IFRAME.

My JavaScript DOM Listings (see signature) include an IFRAME and could
show you the difference between accessing an IFRAME as an element on the
page and as a member of the frames collection.

Richard.
 

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

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top