W3C home > Mailing lists > Public > www-html@w3.org > June 2003

Re: xhtml and javascript

From: Tom Gilder <tom@tom.me.uk>
Date: Sat, 28 Jun 2003 23:52:49 +0100
Message-ID: <4554396890.20030628235249@tom.me.uk>
To: www-html@w3.org

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:55 GMT