Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 9th, 2005, 07:55 PM
Jean Pierre Daviau
Guest
 
Posts: n/a
Default Javascript failing xhtml [xhtml newbe]

Hi,

<script language="javascript" type="text/javascript">
if(navigator.appName.indexOf("Netscape") != -1){
document.writeln('<link rel="stylesheet" href="~styles/aquarelle_ns.css"
type="text/css" media="screen" title="base" />');
}else{
document.write('<link rel="stylesheet" href="~styles/aquarelle.css"
type="text/css" media="screen" title="base" />');
}
</script>

<style type="text/css">
....
</style>
</head>
------------------------------------
Error Line 39 column 118: document type does not allow element "link" here.
....xt/css" media="screen" title="base" />');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).

What can I do?


NB: The html form of it
http://www.jeanpierredaviau.com/aquarelle.html

--

X trême newbe
.......
masm32
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz


  #2  
Old August 9th, 2005, 08:55 PM
David Dorward
Guest
 
Posts: n/a
Default Re: Javascript failing xhtml [xhtml newbe]

Jean Pierre Daviau wrote:


[ inside a <script> ][color=blue]
> Error Line 39 column 118: document type does not allow element "link"
> here. ...xt/css" media="screen" title="base" />');[/color]

http://www.w3.org/TR/xhtml1/#h-4.8
http://www.hixie.ch/advocacy/xhtml

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
  #3  
Old August 9th, 2005, 10:35 PM
Benjamin Niemann
Guest
 
Posts: n/a
Default Re: Javascript failing xhtml [xhtml newbe]

Jean Pierre Daviau wrote:
[color=blue]
> Hi,
>
> <script language="javascript" type="text/javascript">
> if(navigator.appName.indexOf("Netscape") != -1){
> document.writeln('<link rel="stylesheet" href="~styles/aquarelle_ns.css"
> type="text/css" media="screen" title="base" />');
> }else{
> document.write('<link rel="stylesheet" href="~styles/aquarelle.css"
> type="text/css" media="screen" title="base" />');
> }
> </script>
>
> <style type="text/css">
> ...
> </style>
> </head>
> ------------------------------------
> [snip][/color]

The most important issue: document.writeln() does not work in XHTML, if it's
served as application/xhtml+xml. I assume that you are going to do this (at
least with content negotiation, for browsers that support it), because
XHTML is just another form of tagsoup, if served as text/html.

Script snippets that contain '<' or '&' characters must be enclosed in
<[CDATA[ .. ]]> marked sections, otherwise the validator will not parse the
document as you intend it to do (browsers are more tolerant, but I would
not count on it).

This does not happen, if you stick to HTML, because the STYLE element has
the content model CDATA, which means that the parser ignores (e.g. does not
interpret a '<' as the start of a tag) everything until it finds the first
'</' followed by a character 'a..z' or 'A..Z'.

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
  #4  
Old August 13th, 2005, 10:35 PM
Jean Pierre Daviau
Guest
 
Posts: n/a
Default Re: Javascript failing xhtml [xhtml newbe]


| http://www.w3.org/TR/xhtml1/#h-4.8
| http://www.hixie.ch/advocacy/xhtml


How come this page validate sending
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
It does not use the crazy CDAT[[]]?


http://www.kgreene.com/world.php


  #5  
Old August 16th, 2005, 07:35 AM
David Dorward
Guest
 
Posts: n/a
Default Re: Javascript failing xhtml [xhtml newbe]

Jean Pierre Daviau wrote:
[color=blue]
> How come this page validate sending
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
> />
> It does not use the crazy CDAT[[]]?[/color]

(a) That meta tag is mostly rubbish and the real http header will trump it
every time

(b) Validation checks conformance to the DTD. That is entirely independent
of the content type.

(c) You said it didn't validate!

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
  #6  
Old August 16th, 2005, 05:15 PM
Jean Pierre Daviau
Guest
 
Posts: n/a
Default Re: Javascript failing xhtml [xhtml newbe]

[color=blue]
> (c) You said it didn't validate![/color]
Dont misunderstand me, I am just trying to figure out :-)

I did not express myself well.

I was talking about mypage http://www.jeanpierredaviau.com/echangeTidy.html

not this one:
http://www.kgreene.com/world.php

.....................
exerp:
<?xml version="1.0"?>
<!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>kgreene.com :: World boundaries plotter project.</title>
<script type="text/Javascript" src="map.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
..................


Does not it send text/html content? It is suppose to be useless has I red
in the article you refered me.

======
If you use XHTML, you should deliver it with the application/xhtml+xml
MIME type. If you do not do so, you should use HTML4 instead of XHTML.
The alternative, using XHTML but delivering it as text/html, causes
numerous problems that are outlined below.
==============


My question is: is xhtml possible?


  #7  
Old August 16th, 2005, 08:05 PM
David Dorward
Guest
 
Posts: n/a
Default Re: Javascript failing xhtml [xhtml newbe]

Jean Pierre Daviau wrote:

[color=blue]
> Does not it send text/html content?[/color]

Yes, but that has nothing to do with the <meta> tag you put in it.
[color=blue]
> It is suppose to be useless has I red in the article you refered me.[/color]

Sending XHTML as text/html gives you none of the benefits of XHTML (which
are of use to only a very small proportion of authors today anyway), and is
actively harmful in those (admittedly small proportion of) browsers which
implement HTML correctly.
[color=blue]
> My question is: is xhtml possible?[/color]

In 2005 it is mostly pointless and rather impractical.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
  #8  
Old August 16th, 2005, 09:05 PM
Jean Pierre Daviau
Guest
 
Posts: n/a
Default Re: Javascript failing xhtml [xhtml newbe]

[color=blue]
> In 2005 it is mostly pointless and rather impractical.[/color]

I beleive you :-)

Thanks


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles