[thelist] DIV, innerHTML, and Mozilla Compatibility

.jeff jeff at members.evolt.org
Sun Feb 16 12:50:01 CST 2003


abdullah,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Abdullah Shaikh
>
> function get(eN)
> {
>   if(document.getElementById)
>   {
>     return(eval('document.getElementById(\'' + eN + '\')'))
>   }
>   else
>   {
>   if(document.all)
>   {
>     return(eval('document.all.' + eN))
>   }
> }
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

did you totally miss my comments about the use of the eval() method?  it's
completely unnecessary in the function above.  you're making the browser
work harder than it has to every time this function is called.  you make the
script much more difficult to read as you escape characters.  what's more,
your getElementById() method call won't work.  try this instead:

function get(eN)
{
  if(document.getElementById)
    return document.getElementById(eN);
  else if(document.all)
    return document.all[eN];
  else
    return null;
}

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> You can easily extend it by adding an NS4 branch (
> document.layers ) to use NS4 as well for those 1% of
> slackers that haven't upgraded their browsers yet...
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

speaking of slackers ... oh, never mind.

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/




More information about the thelist mailing list