By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,286 Members | 1,589 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,286 IT Pros & Developers. It's quick & easy.

iframe reading problems

P: n/a
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,defaultStat us,document,event
,external,frames,history,Image,length,location,nam e,navigator
,offscreenBuffering,onafterprint,onbeforeprint,onb eforeunload,onblur
,onerror,onfocus,onhelp,onload,onresize,onscroll,o nunload,opener,Option
,parent,screen,screenLeft,screenTop,self,status,to p,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
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Jeff Thies" <cy*******@sprintmail.com> wrote in message
news:3F***************@sprintmail.com...
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:
<snip>
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: <snip> 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.
--

Example JavaScript DOM listings for: Opera 7.11,
Mozilla 1.2 and ICEbrowser 5.4
<URL: http://www.litotes.demon.co.uk/dom_root.html >
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.