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

Posted by Jeff on 10/17/54 12:01

I V wrote:
> 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:

The W3C's.

What happens is that I'm concatenating strings (content += ...) and
it's complaining about closing tags that aren't open (the are opened on
another line). I didn't expect that, I validated it because of the
problem in the next thread and I was surprised to see all that. I've
never used CDATA so I though it was time to learn. I was wrong!

I think I'll just take cwdjrxyz'z advice and ignore them for now. It
will of course wind up in an external file when I get done with writing it.

Thanks,
Jeff
>
> <!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

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