iframe reading problems

Discussion in 'Javascript' started by Jeff Thies, Jul 7, 2003.

  1. Jeff Thies

    Jeff Thies Guest

    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
    Jeff Thies, Jul 7, 2003
    #1
    1. Advertising

  2. "Jeff Thies" <> wrote in message
    news:...
    >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 >
    Richard Cornford, Jul 8, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    669
  2. mi
    Replies:
    4
    Views:
    13,407
    dorayme
    May 21, 2008
  3. elca
    Replies:
    0
    Views:
    556
  4. Daedalous
    Replies:
    3
    Views:
    658
    Daedalous
    Jan 16, 2004
  5. Replies:
    0
    Views:
    110
Loading...

Share This Page