www.webdeveloper.com
Results 1 to 5 of 5

Thread: getElementsByTagName

  1. #1
    Join Date
    Apr 2007
    Posts
    27

    getElementsByTagName

    is getElementsByTagName returns all the tags whether they are in frames/iframes/page ???
    if no then how can i get them

    thnx

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,656
    all the tags of the current document because document.getElementsByTagName

  3. #3
    Join Date
    Apr 2007
    Posts
    27
    document.getElementsByTagName only returns the elements of main document and does not return elements inside iframe

    how can i get All??

  4. #4
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    document.getElementById('frameid').document.getElementsByTagName()

    where frameid is the id associated with the iframe.

  5. #5
    Join Date
    Jan 2005
    Location
    Los Angeles, CA
    Posts
    4,887
    Quote Originally Posted by felgall
    document.getElementById('frameid').document.getElementsByTagName()

    where frameid is the id associated with the iframe.
    nearly. frameid will return a reference to the IFRAME or FRAME element not the actual frame's window.
    Code:
    var allElsInFrameId=
    document.getElementById('frameid').contentWindow.document.getElementsByTagName("*");
    I still prefer the frames[0].document.getElementsByTagName("*") approach though.

    If for some reason one wanted to get every element in every frame combined into a single array of references, one could loop through the frames using frames.length and one by one checking if each frame contains any other frames then one by one executing document.getElementsByTagName("*") on each of the frames then storing the references to each element contained within each frame.
    Last edited by Ultimater; 05-08-2007 at 05:03 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles