Welcome to WebHeadStart.org

Web Technologies

Sponsored By

WebHeadStart.org is currently in beta.
Please pardon our appearance as we work to provide you with the most comprehensive reference on today's web technologies.

Interested in advertising on WebHeadStart? Become an advertising partner today!

[WWW-HTML Mailing List Archive Home] [Messages By Thread] [Messages By Date]

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 GMT
Valid XHTML 1.0! Valid CSS! Site Map | Privacy Policy | Terms of Use | WebHeadStart.org © 2005 All Rights Reserved.