Accessing IFrame anchors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dorinbogdan
    Recognized Expert Contributor
    • Feb 2007
    • 839

    Accessing IFrame anchors

    Let's say that my IFrame has id="container" .
    I can get a reference to it using
    Code:
    var ref = document.getElementById("container");
    I can get an array of all elements using:
    Code:
    ref.document.all
    But, how can I get just anchor elements of ref, without looping through all elements? is there a getElementsByTa gName() method or other way?

    Thanks,
    Dorin.
  • mrhoo
    Contributor
    • Jun 2006
    • 428

    #2
    var ref = document.getEle mentById("conta iner");

    var refdoc=ref.cont entWindow.docum ent;

    refdoc returns the document in the window contained by the Iframe.
    As long as it is in the same domain as the parent page, you can use all of the documen methods you would have access to if you opened the document directly.

    to get the links-
    var linklist=refdoc .getElementsByT agName('a')
    or
    var linklist=refdoc .links

    Comment

    • dorinbogdan
      Recognized Expert Contributor
      • Feb 2007
      • 839

      #3
      Thanks for help, I just found it too.

      God bless you,
      Dorin.

      Comment

      Working...