[Javascript] Something better than getElementById

Roger Roelofs rer at datacompusa.com
Sun Oct 23 08:15:21 CDT 2005


Troy,

On Oct 23, 2005, at 12:08 AM, Troy III Ajnej wrote:

> Sorry, but something like that is possible and still working only in 
> IEssss. The document.getUgly('byW3C.happyforIt') is the 'standard' for 
> now.
>
> -sorry if my post look's ugly, its because I've just installed the 
> firefox, sort of W3C standard!

You're welcome to prefer ie.  It is still the majority browser.  
However, I'm not sure you post was helpful to the person asking the 
question in the first place.  Are you referring to the ie only 
document.all[] collection?  If so, and the original poster is in an ie 
only environment, he can write

      var a = document.all[dest];
      a.className='sel'
instead of
      var a = document.getElementById(dest);
      a.className='sel'

If you hate typing long strings of stuff like document.getElementById, 
(I know that annoys me) you can do this

getId = document.getElementById;
... later in code ....
var a = getIe(dest);

Troy,  I am confidant you know all this, but I know there are scripters 
at all levels on this list who might benefit by an explanation of the 
technique you had in mind.  In fact, I could have completely missed the 
boat in guessing at whet you meant.

Have a great day!

Roger,

Roger Roelofs
Datacomp Appraisal Services




More information about the Javascript mailing list