1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| <script type="text/javascript">
//<![CDATA[
function changemessage() {
var xmldocument = xhr.responseXML;
nodemessage = xmldocument.getElementsByTagName("message");
nodebourse = xmldocument.getElementsByTagName("bourse");
nodecours = xmldocument.getElementsByTagName("cours");
nodevariation = xmldocument.getElementsByTagName("variation");
var textebourse = nodebourse[i].firstChild.nodeValue;
var textecours = nodecours[i].firstChild.nodeValue;
var textevariation = nodevariation[i].firstChild.nodeValue;
document.getElementById("id_bourse").innerHTML = textebourse;
document.getElementById("id_cours").innerHTML = textecours;
document.getElementById("id_variation").innerHTML = textevariation;
i++;
if(i >= nodemessage.length){
i = 0;
}
}
window.onload=initall();
var texte= new Array();
var xmldocument;
var i = 0;
var xhr = null;
function initall(){
if(window.XMLHttpRequest){
var xhr= new XMLHttpRequest();
}
else if (window.ActiveXobject){
xhr= new ActiveXobject("Microsoft.XMLHTTP");
}
else{
alert("Votre navigateur prend pas ajax");
}
if (xhr){
xhr.onreadystatechange= function(){
if (xhr.readyState == 4 && xhr.status == 200) {
interval = setInterval("changemessage()",2000)
}
}
xhr.open("GET","messages.xml",true);
xhr.send(null);
}
}
//]]>
</script>
</head>
<body>
<div id="bloc">
<span id="id_bourse"></span><br>
<span id="id_cours"></span><br>
<span id="id_variation"></span>
</div>
<div style="font-size: 36px; margin-top: 8px;">Contenu</div>
</body>
</html> |
Partager