As a natural starting point for our discussion, consider the following snippet from a Web page: <label>A form with name~"foo"<flabel> </form> A div with id~foo </div>
The excerpt is trivial, and it should be obvious that running a function as simple as document. getElementByld("joo'') would always return the DIV element as a result. As a Linux user, you even could use a Gecko-based browser, such as Firefox, or a KHTML-based browser, such as Konqueror, to test the page and verify it for yourself.
However, you may be alarmed and shocked to learn that running the very same test in Internet Explorer versions 6 or 7 returns the FORM element instead of the DIV element! This particular bug arises, because the name and id attribute namespaces are merged for IE. As it turns out, the DIV would have been returned if the FORM had not appeared first in the document, so this bug is especially tricky. At any rate, Dojo provides the dojo. byld function that works just like document.getElementByld-except that it accounts for this particular issue. Use it to stay safe and to save some typing.




Reply With Quote
Bookmarks