Re: Java script and validator... not the common endtag/backslash error

On Sat, 21 Aug 2004, Jari Porola wrote:

> > The theoretical option is a CDATA section. The
> > practical way (if you care
> > about IE, for example, which is XHTML ignorant and
> > doesn't grok CDATA
> > sections either) is to use workarounds that avoid
> > the constructs that
> > trigger something in #PCDATA parsing.
>
> Both ways seemed to work, but since I have lots of
> those triggering characters I think the CDATA is
> easier way.

Well, they work in the sense of making the document valid
(in the technical XML sense).
But as I wrote, CDATA sections don't work on IE. If you try

<script type="text/javascript"><![CDATA[
  document.write('hello');
]]></script>

you will get just a syntax error on IE, which does not recognize
the <![CDATA[ construct, and therefore doesn't read the
JavaScript code properly.

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/

Received on Sunday, 22 August 2004 05:40:20 UTC