Re: explain what this means
- From: Dr John Stockton <jrs@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 24 Aug 2005 23:20:32 +0100
JRS: In article <0xTOe.5296$iM2.523263@xxxxxxxxxxxxxxx>, dated Wed, 24
Aug 2005 17:25:01, seen in news:comp.lang.javascript, windandwaves
<winandwaves@xxxxxxxxxxxx> posted :
>I found the following function somewhere on the web. I am not sure how it
>works, but I am sure that it is very useful:
>
>function getObj(name) {
> if (document.getElementById){
> if(document.getElementById(name)) {
> if(document.getElementById(name).style) {
> this.obj document.getElementById(name);
> this.style document.getElementById(name);
> }
> }
> }
It looks rather inefficient, as it does the search for name four
times. After removing the actual errors, consider something (untested)
along the lines of
function getObj(name) { var T
if (T = document.getElementById){
if (T = T(name)) {
if (T.style) {
this.obj T;
this.style T;
}
}
}
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
.
- References:
- explain what this means
- From: windandwaves
- explain what this means
- Prev by Date: Re: Conditional onsubmit events
- Next by Date: Re: with and prototype
- Previous by thread: Re: explain what this means
- Next by thread: Re: explain what this means
- Index(es):
Relevant Pages
|
Loading