Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Alternative to document.getElementsByTagName

Posted on 2001-06-25
2
Medium Priority
?
934 Views
Last Modified: 2012-08-14
Is there an alternative to getElementsByTagName that works uniformly for browser versions 4 and uPwards upto version 6 for both IE and NETSCAPE.

Semms getElementsByTagName will work only for browser versions 5 and upwards
0
Comment
Question by:x666xchange
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
CJ_S earned 90 total points
ID: 6224005
there is no uniform way of accomplishing that.

in Netscape you can only do it for layers:
myarray = document.layers

in IE you can use:
document.all.tags("DIV")
or any other kind of tag

in IE 5 + and NS 6 you can use
document.getElementsByTagName("DIV")

regards,
CJ
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6225728
I'm really trying to support that tag in the new sites I'm working on...

that and document.all

those are the two best ways of getting elements in my opinion, and although ns4 makes you jump through hoops to get some elements..I'm hoping that this trend towards a univeral way to access an element is going to develop to a standard ! yes!

anyways, if you are having a problem with getting at something in ns4, then let us try and help, otherwise, if you are just frustrated, welcome to the club.
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question