[Javascript] Something better than getElementById

Troy III Ajnej trojani2000 at hotmail.com
Sun Oct 23 18:14:10 CDT 2005


Not that I'm preferring IE over other browsers, -a browser is a browser. I 
start browsing with
whatever is in front of me. Still I agree that IE is the agent used by 
majority and I encounter
it more often than other browsers. Your post was a good one and I appreciate 
it.

For at least IE 4.1 and later, there is no need to call 'document.all' 
itieration.
You can selectively call/select the element directly from D.O.
In this/his case:

        pictures.className='sel' //direct set of property and still IE only
                                         /*this should rise a naming issue, 
as pictures is a collection entitiy,
                                            but it doesn't! That's because 
... not so important*/

The mate's question was, I guess, something like 'faster method', not only 
(obviously) cleaner,
but faster. I haven't run any tests in comparing IE original syntax with the 
new
getElementById('pictures')
adoption of standard, but as we can see. It involves D.O. collection 
look-up, as a first step and
seccond step: compare them in string  format.
That is two actions and the sllower string method, instead of direct 
selection of D.O. (!Treat this,
only as logical conclusion please).

But possibly the mate noticed some impact on speed of ecxecution, therefore, 
he got curious to
see if there is some other method that could speed his way out.

None that I'm aware of. //-If, cross-browser compatibility is aquired!

But this is an open list and anybody who knows more on this topic is free to 
post solutions.
My 're:' was somewhat tentious because W3C knows how to piss me/lot of us 
off.
But I get happier when I see that more browsers implement at least the 
'innerHTML' property,
dispite the W3C decision. As far as I'm concerned, W3C reinvented the wheel 
with their buggy nodes and made it somewhat: 'eliptic'.
It doesn't Rock'n'Roll at all.

Thank's again

<html><DIV>
<P align=center>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<BR>Troy 
III<BR>progressive art 
enterprise<BR>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</P></DIV></html>



<BLOCKQUOTE style='PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #A0C6E5 
2px solid; MARGIN-RIGHT: 0px'><font 
style='FONT-SIZE:11px;FONT-FAMILY:tahoma,sans-serif'><hr color=#A0C6E5 
size=1>
From:  <i>Roger Roelofs &lt;rer at datacompusa.com&gt;</i><br>Reply-To:  
<i>&quot;\[JavaScript List\]&quot; &lt;javascript at LaTech.edu&gt;</i><br>To:  
<i>&quot;\[JavaScript List\]&quot; 
&lt;javascript at LaTech.edu&gt;</i><br>Subject:  <i>Re: [Javascript] Something 
better than getElementById</i><br>Date:  <i>Sun, 23 Oct 2005 09:15:21 
-0400</i><br>&gt;Troy,<br>&gt;<br>&gt;On Oct 23, 2005, at 12:08 AM, Troy III 
Ajnej wrote:<br>&gt;<br>&gt;&gt;Sorry, but something like that is possible 
and still working only <br>&gt;&gt;in IEssss. The 
document.getUgly('byW3C.happyforIt') is the <br>&gt;&gt;'standard' for 
now.<br>&gt;&gt;<br>&gt;&gt;-sorry if my post look's ugly, its because I've 
just installed the <br>&gt;&gt;firefox, sort of W3C 
standard!<br>&gt;<br>&gt;You're welcome to prefer ie.  It is still the 
majority browser.  <br>&gt;However, I'm not sure you post was helpful to the 
person asking the <br>&gt;question in the first place.  Are you referring to 
the ie only <br>&gt;document.all[] collection?  If so, and the original 
poster is in an <br>&gt;ie only environment, he can write<br>&gt;<br>&gt;    
   var a = document.all[dest];<br>&gt;      a.className='sel'<br>&gt;instead 
of<br>&gt;      var a = document.getElementById(dest);<br>&gt;      
a.className='sel'<br>&gt;<br>&gt;If you hate typing long strings of stuff 
like <br>&gt;document.getElementById, (I know that annoys me) you can do 
this<br>&gt;<br>&gt;getId = document.getElementById;<br>&gt;... later in 
code ....<br>&gt;var a = getIe(dest);<br>&gt;<br>&gt;Troy,  I am confidant 
you know all this, but I know there are <br>&gt;scripters at all levels on 
this list who might benefit by an <br>&gt;explanation of the technique you 
had in mind.  In fact, I could have <br>&gt;completely missed the boat in 
guessing at whet you meant.<br>&gt;<br>&gt;Have a great 
day!<br>&gt;<br>&gt;Roger,<br>&gt;<br>&gt;Roger Roelofs<br>&gt;Datacomp 
Appraisal 
Services<br>&gt;<br>&gt;_______________________________________________<br>&gt;Javascript 
mailing 
list<br>&gt;Javascript at LaTech.edu<br>&gt;https://lists.LaTech.edu/mailman/listinfo/javascript<br></font></BLOCKQUOTE>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/




More information about the Javascript mailing list