References

double-helix
07-14-2002, 05:59 AM
When i use JavaScripts in my HTML code, i reference many thing sso that i may creat innotive and cool scripts. However, one things concerns me.

When i reference a'DHTML Element' eg <span><div> etc, i do this:


document.all["span / div id selector"].property


However, apparently, you can also do this


span/ div id selector.property


I know this is correct, but, as there are compatibilit issues, is one more compatible than the other?
or should i make a simple browser script at the start to justify which one to use?

Any help appreciated :)

Derek Stone
07-14-2002, 03:40 PM
Use the former.

-CL

Rezner
07-16-2002, 05:06 PM
I typically stick with the first method you posted (which is for IE). Since IE and Netscape do this differently, I use browser a detection script. Something like:

<SCRIPT LANGUAGE="JavaScript">
ns = (document.layers)?
true:false //check for netscape
ie = (document.all)? true:false //check for internet explorer

function SetProp()
{

if (ns)
document.layers[<<SPAN/DIV>>].<<PROPERTY>>;
else
document.all[<<SPAN/DIV>>].style.<<PROPERTY>>;

}

</SCRIPT>

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum