You are here: Re: cdata and javascript « HTML « IT news, forums, messages
Re: cdata and javascript

Posted by I V on 10/03/29 12:01

On Sat, 26 Jan 2008 16:49:13 -0500, Jeff wrote:
> Why not? If I want to validate the page as I'm working on it I won't
> have to wade through the 47 errors the validator thinks it sees in the
> javascript where I'm assembling bits of html.

What validator are you using? In HTML (but not XHTML), the content of a
script element is already considered CDATA, so the validator shouldn't
complain about HTML fragments in the script. I've just checked the W3C's
validator and it thinks this is valid, for instance:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>I AM YOUR DOCUMENT TITLE REPLACE ME</title>
<script type="text/javascript">
document.write('<foobar>');
</script>
</head>
<body>
<p>
Something in the body.
</p>
</body>
</html>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация