iFrame parent object? I' a bit lost.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gsb

    #1

    iFrame parent object? I' a bit lost.

    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


  • Martin Honnen

    #2
    Re: iFrame parent object? I' a bit lost.



    gsb wrote:
    [color=blue]
    > 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?[/color]

    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 .getElementsByT agName('iframe' )
    and compare name or location to find the relevant <iframe> element and
    could then access the div as the parentNode

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    • gsb

      #3
      Re: iFrame parent object? I' a bit lost.

      Martin Honnen,

      Thank you for your time and answer.

      gsb


      Comment

      Working...