SGML Parser doesn't like <script> contents?

P

(Pete Cresswell)

This code:
--------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base target="40thPix_DisplayArea"/>
<title> Click on a small picture...</title>
<link rel="stylesheet" type="text/css" href="Master.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</head>

<body>
<script type="text/javascript">
document.write("<p id='ThumbNavListloading'>Loading thumbnails, please
wait...<\/p>");
........
</script>
--------------

makes the W3C's SGML parser flag the 'document.write' line with
-------------------------------------
Line 12, column 45: document type does not allow element "p" here

....nt.write("<p id='ThumbNavListloading'>Loading thumbnails, please wait...<\/p>

The element named above was found in a context where it is not allowed. This
could mean that you have incorrectly nested elements -- such as a "style"
element in the "body" section instead of inside "head" -- or two elements that
overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML documents.
Due to HTML's rules of implicitly closed elements, this error can create
cascading effects. For instance, using XHTML's "self-closing" tags for "meta"
and "link" in the "head" section of a HTML document may cause the parser to
infer the end of the "head" section and the beginning of the "body" section
(where "link" and "meta" are not allowed; hence the reported error).
-------------------------------------

Seems like it's not buying the <script> command - but the code works, so
*somebody* is recognizing it.

Can anybody tell me where I've sinned?
 
O

Oli Filth

From what I remember, it's good practice to always surround your
Javascript with comment delimiters, e.g.

<SCRIPT type="text/javascript">
<!--
.... script goes here ...
//-->
</SCRIPT>

That way, anything that doesn't know Javascript won't see it, because
it's commented out.

Oli
 
R

rf

wrote:Oli Filth wrote:
(Pete Cresswell) said:
From what I remember, it's good practice to always surround your
Javascript with comment delimiters, e.g.

<SCRIPT type="text/javascript">
<!--
... script goes here ...
//-->
</SCRIPT>

That way, anything that doesn't know Javascript won't see it, because
it's commented out.

Nope. That is cargo cult stuff that went out of fashion with release 3
browsers.

In XHTML anything inside a script element is cdata and should be marked as
such:

<SCRIPT type="text/javascript">
<![cdata[
.... script goes here ...
]]>
</SCRIPT>

google for "xhtml cdata".

The (better) alternative is put the javascript in an external file and link
to it.


Pete, if you are going to all the hassle of using XHTML (including the fact
that IE does not understand it) why are you using transitional rather than
strict?
 
O

Oli Filth

Oh, sorry, didn't spot the XHTML doctype. I stand corrected.

Oli
wrote:Oli Filth wrote:
(Pete Cresswell) wrote:

From what I remember, it's good practice to always surround your
Javascript with comment delimiters, e.g.

<SCRIPT type="text/javascript">
<!--
... script goes here ...
//-->
</SCRIPT>

That way, anything that doesn't know Javascript won't see it, because
it's commented out.


Nope. That is cargo cult stuff that went out of fashion with release 3
browsers.

In XHTML anything inside a script element is cdata and should be marked as
such:

<SCRIPT type="text/javascript">
<![cdata[
... script goes here ...
]]>
</SCRIPT>

google for "xhtml cdata".

The (better) alternative is put the javascript in an external file and link
to it.




Pete, if you are going to all the hassle of using XHTML (including the fact
that IE does not understand it) why are you using transitional rather than
strict?
 
D

Duende

While sitting in a puddle rf scribbled in the mud:
The (better) alternative is put the javascript in an external file and link
to it.

The best place to put it is... Recycle Bin
 
P

Phoenix

(Pete Cresswell) wrote:

<body>
<script type="text/javascript">
document.write("<p id='ThumbNavListloading'>Loading thumbnails, please
wait...<\/p>");
.......
</script>

Seems like it's not buying the <script> command - but the code works, so
*somebody* is recognizing it.

Can anybody tell me where I've sinned?

Notice also, that if you are ever going to send this as TRUE XHTML (that
is with the document type of "application/xhtml+xml" and not as HTML
(text/html), document.write() will stop working.
 
D

David Håsäther

No, it's not commented out (supposing this is CDATA declared content),
although in a UA that doesn't support the SCRIPT element type it will
likely be, yes. But as rf said, this is things that belongs to the
past.
In XHTML anything inside a script element is cdata

No, the content model for script is (#PCDATA) in XHTML.
 
D

Dylan Parry

Neal said:
I'm not happy... <snip/>

Can't please everyone ;)

The OP wants to use Javascript, Oli wants to use comments to hide it,
Richard wants to use CDATA, David wants PCDATA, and Duende wants the OP
to not use Javascript at all :s

Me? I'm indifferent ;)
 
P

(Pete Cresswell)

RE/
Pete, if you are going to all the hassle of using XHTML (including the fact
that IE does not understand it) why are you using transitional rather than
strict?

Because I'm still suffering from RCI HTML-wise.

I probably copied that line from somewhere and it worked...so I never touched
it.

I've gotten all my code through W3C's parser with no fatals - as "Transitional".
Sounds like it's time to find an upgraded !DOCTYPE statement and try strict
 
P

(Pete Cresswell)

RE/
Notice also, that if you are ever going to send this as TRUE XHTML (that
is with the document type of "application/xhtml+xml" and not as HTML
(text/html), document.write() will stop working.

That's definately in the works.

Which remedy should I adopt?

<![cdata[......]]> ?
 
P

(Pete Cresswell)

RE/
Notice also, that if you are ever going to send this as TRUE XHTML (that
is with the document type of "application/xhtml+xml" and not as HTML
(text/html), document.write() will stop working.

Can somebody point me to a page that asks for full enforcement of true XHTML?

I've looked through a half-dozen and found mostly HTML.
 
N

Neal

RE/

Are XHTML and CSS inextricably intertwined or can I base formatting on a
common
CSS file and still use plain-vanilla HTML?

The elements in XHTML 1.0 and HTML 4.01 are identical, so the stylesheet
should not have to change.
 
D

Dylan Parry

(Pete Cresswell) said:
Are XHTML and CSS inextricably intertwined or can I base formatting on a common
CSS file and still use plain-vanilla HTML?

XHTML *is* HTML just with an X. There's no reason for you not to use CSS
with either. So, no they are not intertwined, and you can use CSS with
HTML as well as with XHTML
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top