![]() |
|
|
|||||||
![]() |
HTML - SGML Parser doesn't like <script> contents? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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? -- PeteCresswell (Pete Cresswell) |
|
|
|
|
#2 |
|
Posts: n/a
|
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 (Pete Cresswell) wrote: > 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? |
|
|
|
#3 |
|
Posts: n/a
|
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. >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 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? -- Cheers Richard. |
|
|
|
#4 |
|
Posts: n/a
|
RE/
>it's good practice to always surround your >Javascript with comment delimiters, e.g. Bingo! And everybody's happy... Thanks. -- PeteCresswell |
|
|
|
#5 |
|
Posts: n/a
|
On Fri, 24 Dec 2004 02:14:29 GMT, (Pete Cresswell) <> wrote:
> RE/ >> it's good practice to always surround your >> Javascript with comment delimiters, e.g. > > Bingo! And everybody's happy... I'm not happy... see rf's response for a more appropriate solution. |
|
|
|
#6 |
|
Posts: n/a
|
Oh, sorry, didn't spot the XHTML doctype. I stand corrected.
Oli rf wrote: > 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. > > > >>><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > > > 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? > |
|
|
|
#7 |
|
Posts: n/a
|
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 -- D? If it ain't broken fix it anyway. |
|
|
|
#8 |
|
Posts: n/a
|
(Pete Cresswell) wrote:
<snip> > <body> > <script type="text/javascript"> > document.write("<p id='ThumbNavListloading'>Loading thumbnails, please > wait...<\/p>"); > ....... > </script> <snip> > 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. |
|
|
|
#9 |
|
Posts: n/a
|
rf <rf@.invalid> wrote:
> Oli Filth 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. 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. -- David Håsäther |
|
|
|
#10 |
|
Posts: n/a
|
Neal wrote:
>> Bingo! And everybody's happy... > > 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 -- Dylan Parry http://webpageworkshop.co.uk -- FREE Web tutorials and references |
|