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