Javascript et w3c

cs_dadateite
Messages postés
2
Date d'inscription
dimanche 30 septembre 2007
Statut
Membre
Dernière intervention
25 mai 2009
- 25 mai 2009 à 09:28
psyckan
Messages postés
135
Date d'inscription
vendredi 27 août 2004
Statut
Membre
Dernière intervention
8 mai 2010
- 25 mai 2009 à 11:28
j'aimerais faire passer ce script aux normes W3C mais il ne pass epas:
<script language="javascript">

<!-- DEBUT DU SCRIPT -->
/*
Snow Effect Script
Created and submitted by Altan d.o.o. (snow@altan.hr, http://www.altan.hr/snow/index.html)

EDITE SUR L'EDITEUR JAVASCRIPT
http://www.editeurjavascript.com
*/

var snowsrc="images/goutte.png"
var snowsrc2="images/goutte2.png"
var no = 3;/*ici on change le nombre de goutte a afficher en meme temps sur l'ecran*/
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var nn6up = (document.getElementById) ? 1 : 0;
var dx, xp, yp;
var am, stx, sty;
var i, doc_width 800, doc_height 600;

if (ns4up)
{
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}

else if (ie4up)
{
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}

else if (nn6up)
{
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}

dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();

for (i = 0; i<no; ++ i)
{
dx[i] = 0;
xp[i] = Math.random()*(doc_width-50);
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();

if (ns4up)
{
if (i == 0)
{
document.write("<layer name=dot"+ i +" left=15 top=15 visibility=show></layer>");
}

else
{
document.write("<layer name=dot"+ i +" left=15 top=15 visibility=show></layer>");
}
}

else if (ie4up || nn6up)
{
if (i == 0)
{
document.write("

");
}

else
{
document.write("

");
}
}
}

function snowNS()
{
for (i = 0; i < no; ++ i)
{
yp[i] += sty[i];
if (yp[i] > doc_height-50)
{
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}

dx[i] += stx[i];
document.layers["dot"+i].top = yp[i];
document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowNS()", 10);
}

function snowIE()
{
for (i = 0; i < no; ++ i)
{
yp[i] += sty[i];
if (yp[i] > doc_height-50)
{
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}

dx[i] += stx[i];
document.all["dot"+i].style.pixelTop = yp[i];
document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowIE()", 10);
}

function snowNN6()
{
for (i = 0; i < no; ++ i)
{
yp[i] += sty[i];
if (yp[i] > doc_height-50)
{
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}

dx[i] += stx[i];
document.getElementById("dot"+i).style.top = yp[i];
document.getElementById("dot"+i).style.left = xp[i] + am[i]*Math.sin(dx[i]);
}

setTimeout("snowNN6()", 3);/*vitess des gouttes*/

}
if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
} else if (nn6up) {
snowNN6();
}

</script>

<!-- FIN DU SCRIPT -->

et voici les debuts d'erreurs:
Line 309, Column 30: required attribute "type" not specified
<script language="javascript">



The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.
Line 355, Column 23: character ";" not allowed in attribute specification list
for (i = 0; i<no; ++ i)


Line 355, Column 23: element "no" undefined. Did you mean "noframes" or "noscript"?
for (i = 0; i<no; ++ i)



You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by:
incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element),
by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead).
by using upper-case tags in XHTML (in XHTML attributes and elements must be all lower-case).
Line 368, Column 36: Attribute "name" exists, but can not be used for this element.
document.write("<layer name=dot"+ i +" left=15 top=15 visibility=show> element to incorporate flash media in a Web page, see the FAQ item on valid flash.



merci de m'aider

1 réponse

psyckan
Messages postés
135
Date d'inscription
vendredi 27 août 2004
Statut
Membre
Dernière intervention
8 mai 2010

25 mai 2009 à 11:28
Bonjour,

Plusieurs choses :
- rajoute type="text/javascript" à ta balise <script>
- Je ne pense pas que la balise <layer> soie reconnu par W3C
- Tes attributs left et top doivent comporter une unité or tu à ça par exemple :

document.getElementById("dot"+i).style.top = yp[i];

à remplacé par : document.getElementById("dot"+i).style.top = yp[i]+'px';

Je ne sais pas pour les attributs pixelTop et pixelLeft, mais ça doit surement être pareil
0