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

Re: xhtml and javascript

From: Ian Hickson <ian@hixie.ch>
Date: Sat, 28 Jun 2003 14:18:11 -0700 (PDT)
To: Tom Gilder <tom@tom.me.uk>
Cc: "www-html@w3.org" <www-html@w3.org>
Message-ID: <Pine.LNX.4.56.0306281415070.18309@dhalsim.dreamhost.com>

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">
     /* in an XHTML document this would have to use createElementNS(), not
        createElement(), but that's another story */
     var element = document.createElement('INPUT');
     element.onclick = function() { ... };
     // etc...
     document.getElementById('hook').appendChild(element);
   </script>

(The above might need some tweaks to work in legacy UAs like Windows IE6,
but the basic principle should work in any UA with DOM1 support.)

-- 
Ian Hickson                                      )\._.,--....,'``.    fL
"meow"                                          /,   _.. \   _\  ;`._ ,.
http://index.hixie.ch/                         `._.-(,_..'--(,_..'`-.;.'
Received on Saturday, 28 June 2003 17:18:11 GMT

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