By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,341 Members | 1,395 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,341 IT Pros & Developers. It's quick & easy.

XHTML: <![CDATA[..script..]]>

P: n/a
Hi there,
can anybody help me?

It won't work! Why?
My declaration:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Title</title>
<script language="JavaScript1.1" type="text/javascript">
<![CDATA[
<!--
...script ...
// -->
]]>
</script>
</head>
<body>
<noscript>
<p>Noscript</p>
</noscript>
</body>
</html>

It works without "<![CDATA[..script..]]>"!
Thanks for helping!
Ralf
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Ralf Schneider wrote:
It won't work! Why?
My declaration:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <script language="JavaScript1.1" type="text/javascript">
No language attribute in Strict
<![CDATA[
OK I think...
<!--


Why do you have an SGML comment in there?
--
David Dorward http://dorward.me.uk/
Jul 20 '05 #2

P: n/a


Ralf Schneider wrote:
Hi there,
can anybody help me?

It won't work! Why?
What does won't work mean? Doesn't the page validate? Or is the script
causing script errors?
My declaration:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Title</title>
<script language="JavaScript1.1" type="text/javascript">
<![CDATA[
<!--
...script ...
// -->
]]>
</script>


You need
<script type="text/javascript">
<![CDATA[
script code
]]>
</script>
for a XHTML page served as XML (text/xml, application/xml,
application/xhtml+xml) to a browser.

If you want your page to be served as text/html to a HTML browser like
IE then you need
<script type="text/javascript">
//<![CDATA[
script code
//]]>
</script>
as an HTML parser doesn't know about CDATA sections

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.