[Javascript] getElementsByTagName("*") to get all elements

Paul Novitski paul at novitskisoftware.com
Tue Jul 26 02:09:41 CDT 2005


Friends,

I want to use getElementsByTagName("*") -- with an asterisk in place of a 
tagName -- to return an array of all elements on the page regardless of 
their 'generation' or 'nest depth' -- as contrasted with childNodes() which 
returns only first-generation children of the parent.

Here's a quickie test script that demonstrates both methods:
http://novitskisoftware.com/demos/gettingAllElements/

The getElementsByTagName("*") method works fine in the latest-version 
Windows browsers I've tested it in (Mozilla & IE).

Does anyone know of a browser that supports getElementsByTagName() but 
DOESN'T support the use of an asterisk in place of a literal tag name?

Thanks,
Paul 





More information about the Javascript mailing list