Subj : Re: javascript sample not working - bug in mozilla? plz help To : netscape.public.mozilla.jseng,netscape.public.mozilla.dom From : Brendan Eich Date : Sat Jun 07 2003 03:01 pm Georg Maaß wrote: > stan k. wrote: > >> Just as a note to those looking in newsgroups - I also had to chagne >> the following to get it to work: >> >> objDiv = divColl(i); >> changed to: >> objDiv = divColl[i]; > > > In Mozilla and W3C DOM collections are variants of arrays. In IE they > are special functions. This is the reason. why there the call operator > is supported, but not on Mozilla neither any W3C conform implementation. Just to be crystal-clear, both forms work in IE, so one should use the [] operator for cross-browser portability. > >> objDiv = eval(sDivID); >> changed to >> objDiv = document.getElementById(sDivID); > > > This uses IE DOM instead of W3C DOM. The eval is unnecessary and costly, even in IE. Another IE-only way to write this is window[sDivID] or self[sDivID]. This works because in IE, document elements induce properties of the window object, named by id attribute values. But don't use any of that, as Georg's post reinforces here -- use document.getElementById for cross-browser, open-standards-based scripting. /be .