Prob validation

ashpo -  
 ashpo -
Bonsoir,
En faite je fai du javascript avec un tableau pour afficher plusieur couleur mais lorsque j'essaie de le valider à l'aide du W3C il me dit une erreur a ce niveau...

Voici le code:
<script type="text/javascript">
m="<table border='0'>";
m+="<tr>";
for (i=0; i<tab.length; i++) {
m+="<td style='background:url(\"Images/"+tab[i]+".png\");' onclick='changecoul(\""+tab[i]+"\")'></td>";
}
m+="</tr>";
m+="</table>";
document.getElementById("couleur").innerHTML=m;
</script>

Voici l'erreur du W3C:
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).

SVP AIDEZ-MOI!!! Je ne sais plus quoi faire...

4 réponses

avion-f16 Messages postés 20368 Date d'inscription   Statut Contributeur Dernière intervention   4 510
 
Salut.

Je pense que le problème se situe avant.
N'aurais-tu pas oublié de fermer une balise ? Ou bien tu n'as peut-être pas fermé correctement une balise auto-fermante (avec "/>" au bout, comme <link />, <meta />, ...).
Ou tu as peut-être placer une balise dans le body alors qu'elle ne peut se situer que dans le head.
0
ashpo
 
Ceci est mon code en entier: et franchement je ne vois pas trop ce ki cloche :s

<!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="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<script src="Js/change_couleur.js" type="text/javascript"></script>
<title>Site </title>
<link rel="stylesheet" media="screen" href="Css/index.css" />
<link rel="stylesheet" media="screen" href="Css/960.css" />
</head>
<body id="change">
<div class="container_24">
<div class="grid_24" id="titre"></div>

<div class="grid_8 prefix_20" id="couleur">
<script type="text/javascript">
m="<table border='0'>";
m+="<tr>";
for (i=0; i<tab.length; i++) {
m+="<td style='background:url(\"Images/"+tab[i]+".png\");width:30px;height:30px;border:solid black 2px;' onclick='changecoul(\""+tab[i]+"\")'></td>";
}
m+="</tr>";
m+="</table>";
document.getElementById("couleur").innerHTML=m;
</script>
</div>
0
Profil bloqué
 
salut
Essayes de fermer le div de la ligne 12 et le body
0
ashpo
 
Salut,
Mon div et mon body se ferme je ne le montre pas c tout
0
HostOfSeraphim Messages postés 7340 Statut Contributeur 1 608
 
D'où l'intérêt de montrer le code en entier... ;-) (d'autant que tu précisais quand même "en entier")
0
ashpo
 
Oui oui je sais dsl mais cela ne resout pas mon probleme donc je recommence :D

Voici le code:

<!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="fr" lang="fr">
<head>

<title>Site </title>
<script src="Js/change_couleur.js" type="text/javascript"></script>
<link rel="stylesheet" media="screen" href="Css/index.css" />
<link rel="stylesheet" media="screen" href="Css/960.css" />
</head>
<body id="change">
<div class="container_24">
<div class="grid_24" id="titre"></div>

<div class="grid_8 prefix_20" id="couleur">
<script type="text/javascript">
m="<table>";
m+="<tr>";
for (i=0; i<tab.length; i++) {
m+="<td style='background:url(\"Images/"+tab[i]+".png\");width:30px;height:30px;border:solid black 2px;' onclick='changecoul(\""+tab[i]+"\")'></td>";
}
m+="</tr>";
m+="</table>";
document.getElementById("couleur").innerHTML=m;
</script>
</div>

<div class="grid_8" id="labo">
<img src="Images/labos.png" alt="labos" />
</div>

<div class="grid_8" id="presentation">
<p> Test </p>
</div>

<div class="grid_8" id="contact">
<img src="Images/contact.png" alt="contact" />
</div>

<div class="grid_8 suffix_16">
Ce site est en construction
</div>

</div>
</body>
</html>


Et revoici l'erreur di par w3c :
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).
0
Profil bloqué
 
Et ta variable "tab" tu l'avais defini ou et comment ?
0
ashpo
 
euh vu la pro ke je suis la dedans :p je ne l'ai pas defini car ca fonctionne comme ca...
0