11548 sujets

JavaScript, DOM et API Web HTML5

Voila dans cette page dans le menu de droite j'utilise un script "de news"
quand je teste ma page avec http://validator.w3.org/ et que je teste j'ai des erreurs.
Quelqu'un pourrait il me nettoyer se code car je ne suis pas assez malin pour ça

Line 86, column 91: document type does not allow element "a" here
Line 87, column 71: document type does not allow element "a" here
Line 100, column 22: required attribute "type" not specified
Line 100, column 22: document type does not allow element "style" here
Line 101, column 123: document type does not allow element "div"here



voici le sript que j'ai utilise




<script type="text/javascript">

// Highlighter Scroller II script- By JavaScript Kit (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit  http://www.javascriptkit.com/
 
// This notice must stay intact

//CONFIGURE MESSAGES AND VARIABLES
var tickercontents=new Array()
tickercontents[0]='Visitez le site de machin, Pour visitez <a href="http://www.machin.com ">Allez Go</a>!'
tickercontents[1]='Hop on over to <a href="http://www.codingforums.com">Coding Forums</a> to get help on web coding!'
tickercontents[2]='This scroller\'s brought to you by <a href="http://www.javascriptkit.com">JavaScript Kit</a>- Free scripts and tutorials!'

var tickerwidth="170px"
var tickerheight="90px"
var fontcss="font: bold 14px Verdana; color:black"
var tickdelay=3000 //delay btw messages
var highlightspeed=2 //2 pixels at a time.
var highlightcolor="#4494D3"
var backdroptextcolor="#E1E1E1"

////Do not edit pass this line////////////////

document.write('<style>#highlighterbg a{color:'+backdroptextcolor+'}</style>')
document.write('<div style="position:relative;left:0px;top:0px; width:'+tickerwidth+'; height:'+tickerheight+';'+fontcss+'">')
document.write('<span id="highlighterbg" style="position:absolute;left:0;top:0;color:'+backdroptextcolor+'; width:'+tickerwidth+'; height:'+tickerheight+';padding: 4px"></span><span id="highlighter" style="position:absolute;left:0;top:0;clip:rect(auto auto auto 0px); background-color:'+highlightcolor+'; width:'+tickerwidth+';height:'+tickerheight+';padding: 4px"></span>')
document.write('</div>')

var currentmessage=0
var clipbottom=1

function changetickercontent(){
msgheight=clipbottom=crosstick.offsetHeight
crosstick.style.clip="rect("+msgheight+"px auto auto 0px)"
crosstickbg.innerHTML=tickercontents[currentmessage]
crosstick.innerHTML=tickercontents[currentmessage]
highlightmsg()
}

function highlightmsg(){
//var msgheight=crosstick.offsetHeight
if (clipbottom>0){
clipbottom-=highlightspeed
crosstick.style.clip="rect("+clipbottom+"px auto auto 0px)"
beginclip=setTimeout("highlightmsg()",20)
}
else{
clipbottom=msgheight
clearTimeout(beginclip)
if (currentmessage==tickercontents.length-1) currentmessage=0
else currentmessage++
setTimeout("changetickercontent()",tickdelay)
}
}

function start_ticking(){
crosstickbg=document.getElementById? document.getElementById("highlighterbg") : document.all.highlighterbg
crosstick=document.getElementById? document.getElementById("highlighter") : document.all.highlighter
crosstickParent=crosstick.parentNode? crosstick.parentNode : crosstick.parentElement
if (parseInt(crosstick.offsetHeight)>0)
crosstickParent.style.height=crosstick.offsetHeight+'px'
else
setTimeout("crosstickParent.style.height=crosstick.offsetHeight+'px'",100) //delay for Mozilla's sake
changetickercontent()
}

if (document.all || document.getElementById)
window.onload=start_ticking
 </script>

Modifié par hitcher (14 May 2005 - 13:55)

Line 86, column 91: document type does not allow element "a" here
Line 87, column 71: document type does not allow element "a" here
Line 100, column 22: required attribute "type" not specified
Line 100, column 22: document type does not allow element "style" here
Line 101, column 123: document type does not allow element "div"here


Tu aurais une page d'exemple ?

Comme ça, je dirais que tu as mis tes éléments a directement dans le body (ce n'est pas valide, il faut qu'ils soient dans un conteneur bloc)

Pour le type , ça doit provenir de la balise style (qui doit avoir un type="text/css").

De plus on ne peut pas mettre <style> un peu partout façon "je saupoudre de css", mais il faut les régrouper dans le head (ou mieux: dans une feuille de style externe)

Smiley smile