Re: xhtml and javascript

On Saturday, June 28, 2003, 10:18:11 PM, Ian Hickson wrote:
> On Sat, 28 Jun 2003, Tom Gilder wrote:
> > You could of course use the DOM to generate the checkbox, but you'd
> > have to wait for onload to fire, which is a bad thing
> 
> You shouldn't need to:
>
>    <div id="hook"></div>
>    <script type="application/x-javascript">
>      var element = document.createElement('INPUT');
>      document.getElementById('hook').appendChild(element);
>    </script>

That should work, yes, but sadly IE/win is extremely buggy (and I
think I had problems with another browser at some point too, but my
mind has gone blank) with modifying the DOM before it's all loaded.
Often it comes up with "unknown runtime error" or just stops loading
the document full stop.

It's *much* safer in my experience to use document.write (when using
HTML, anyway). Using DOM to generate a lot of content can also get
extraordinarily messy after a while.

-- 
Tom Gilder, http://tom.me.uk/
 Blog! http://blog.tom.me.uk/

Received on Saturday, 28 June 2003 18:52:59 UTC