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

Javascript failing xhtml [xhtml newbe]

P: n/a
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
Aug 9 '05 #1
Share this Question
Share on Google+
7 Replies

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


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
Aug 9 '05 #2

P: n/a
Jean Pierre Daviau wrote:
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]


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/
Aug 9 '05 #3

P: n/a

| 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
Aug 13 '05 #4

P: n/a
Jean Pierre Daviau wrote:
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[[]]?


(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
Aug 16 '05 #5

P: n/a
(c) You said it didn't validate!

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?
Aug 16 '05 #6

P: n/a
Jean Pierre Daviau wrote:

Does not it send text/html content?
Yes, but that has nothing to do with the <meta> tag you put in it.
It is suppose to be useless has I red in the article you refered me.
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.
My question is: is xhtml possible?


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
Aug 16 '05 #7

P: n/a
In 2005 it is mostly pointless and rather impractical.


I beleive you :-)

Thanks
Aug 16 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.