Hi,
The following code displays simultaneously a text message and makes an image move around. However, the first message (quotations[0]) doesn't appear when the corresponding image moves (but the following text messages (1,2, and so on) appear correctly). And under Firefox, I receive this notice:
Élément référencé par son ID/NAME dans le contexte global. Utilisez la propriété standard du W3C « document.getElementById() » à la place.
Someone could help me with this issue?
Thanks in advance
Code:<!DOCTYPE PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Demo</title> <script language="JavaScript"> var quotations = new Array() quotations[0]= "Message 0" quotations[1]= "Message 1" quotations[2]= "Message 2" function cpSequencer(n) { switch(n) { case 0: moveObjLeft(JS, 500, 400, 4); //ID-PX départ-Px fin-Vitesse document.getElementById('quotation').innerHTML=quotations[0] break; case 1: moveObjLeft(JS, 400, 250, 4); //ID-PX départ-Px fin-Vitesse document.getElementById('quotation').innerHTML=quotations[1] break; case 2: moveObjLeft(JS, 250, 50, 4); //ID-PX départ-Px fin-Vitesse document.getElementById('quotation').innerHTML=quotations[2] break; default: break; } } i=0; function moveObjRight(obj, START, END, SPEED) { obj.style.left=START; START+=SPEED; if(START<END) window.setTimeout("moveObjRight(" +obj.id+", " +START+ ", " +END+ ", " +SPEED+ ");", 0); else { i++; setTimeout("cpSequencer(i);",2000) } } function moveObjLeft(obj, START, END, SPEED) { obj.style.left=START; START-=SPEED; if(START>END) window.setTimeout("moveObjLeft(" +obj.id+", " +START+ ", " +END+ ", " +SPEED+ ");", 0); else { i++; setTimeout("cpSequencer(i);",2000) } } </script> </head> <body> <table BACKGROUND="bg.png" width="1730" height="736" border="1"><tr><td> </td></tr></table> <p><img id="JS" style="z-index: 0; left: -100px; position: absolute; top: 12px" height=730 width=3 align=baseline border=0 hspace=0 src="image.jpg"></p> <script language="JavaScript"> cpSequencer(0); </script> <div id="quotation"></div> </body> </html>



Reply With Quote

Bookmarks