Dr John Stockton said the following on 4/14/2006 1:30 PM:[color=blue]
> JRS: In article <123t0hatj3vcj84@corp.supernews.com>, dated Thu, 13 Apr
> 2006 09:56:00 remote, seen in news:comp.lang.javascript, Tony <tony23@ds
> lextreme.WHATISTHIS.com> posted :[color=green]
>> why not
>>
>> if (document.getElementById('product')) {
>> // code here when the element exists
>> }
>>[/color]
>
>
> or, untested but for efficiency,
>
> if ( T = document.getElementById('product') ) {
> // code herein when the element exists, using T
> }
>
> or
>
> if ( !(T = document.getElementById('product') ) ) { AbandonShip() }
> // code hereon when the element exists, using T
>[/color]
The one drawback/possible failure would be in IE where you have an
element with a name or ID of T, then it would clash and crash. Other
than that, its ok code.
--
Randy
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/