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 21:51:41 +0100
Message-ID: <19847128609.20030628215141@tom.me.uk>
To: www-html@w3.org

On Saturday, June 28, 2003, 3:07:46 PM, Jens Meiert wrote:
> > <p>Here is a
> > <script>
> > document.write("complete paragraph<");
> > document.write("/p>");
> > </script>
> The silly thing is to generate markup by scripts (imagine if
> JavaScript is disabled). 

It's easy to jump to the conclusion that generating markup from script
is always an awful thing to do - but there are some cases where it's
extremely handy.

Imagine if you wanted to have an element on the page that only had a
point in existing when scripting is enabled, like, for instance, a
checkbox that allows all links on the page to open in a new window.

If the checkbox was in the HTML as it was, then it would actually
makes things worse for users with no scripting - they'd have a useless
and pointless checkbox.

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 - it would mean
the page would most likely jump down when the checkbox was inserted,
and if for some freak reason the page didn't ever load (an endlessly
loading image, for example), then the checkbox would never appear.

Tom Gilder, http://tom.me.uk/
 Blog! http://blog.tom.me.uk/
Received on Saturday, 28 June 2003 16:51:43 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:06:04 UTC