[thelist] DOM in Mozilla

S.tygian B.lacksmith S.tudios studio at zero.zero.xs2.net
Thu Oct 31 07:49:00 CST 2002


I just tested this myself in Mozilla 1.2b and IE6 SP1 running on Windows
XP Pro. It didn't work in either one.... The problem is that, as
written, you're assigning the nodes to the variables before the page has
rendered completely. Wrap the script that you have in a function
declaration and call it onload - that fixed it for me in both browsers.

Seems to be a common pitfall. ;)

HTH,
S. G.

> <p>
> <label for="searchField" id="searchLabel">Find</label>
> <input type="text" name="keywords" id="searchField" />
> </p>
>
> <script type="text/javascript">
> <!--
>
> theLabel = document.getElementById("searchLabel");
> theField = document.getElementById("searchField");
>
> theField.value = theLabel.firstChild.nodeValue;
> theLabel.style.display = 'none';
>
> // -->
> </script>
>
> Doctype is XHTML Transitional. Mozilla 1.2Beta. IE6 no service
> packs.
>
> _nmk





More information about the thelist mailing list