Adventures As Me


Gecko DOM oddity

Written 22 Sep 2004
<p><del datetime="2004-9-22T09:52:30-05:00">While writing some DOM parsing code for client-side form validation, I encountered an oddity with recent gecko based browsers. Rather than displaying a Javascript alert box, I'm creating textnodes and appending them to an existing DIV. The text contains statements detailing the errors with the form, and instructions to fix the errors. Intially I hid the DIV using the following CSS:</del></p>
<pre>   .messageBox{
display: none;
visibility: hidden; }</pre>
<p><del datetime="2004-9-22T09:52:30-05:00">To create the messages, I used the standard DOM methods<em>appendChild, createElement </em>and<em>createTextNode</em>. Inspecting the result with FireFox's DOM inspector showed the text was there, but it never displayed. This even though I changed the containing DIV style to:</del></p>
<pre>   display: block;   visibility: visible;

</pre> <p>The solution? Quite simple actually, do not try to hide the DIV. That’s right, do not set display: none and visibility: hidden. It will not work.</p>

This is tested with FireFox 0.9.2.

Dur (slaps head). It was a stupid typo.

Related Posts