Besoin d'explication d'un script

Besoin d'explication d'un script - HTML/CSS - Programmation

Marsh Posté le 31-03-2006 à 10:04:36    

Boujour,
 
J'ai trouvé un script sur internet, qui marche trés bien d'ailleurs, mais j'aurais besoin de l'adapter et j'ai un peu du mal a comprendre son fonctionnement.
Voila le code:
imgPath = new Array;
SiClickGoTo = new Array;
if (document.images)
 {
 i0 = new Image;
 i0.src = './images/anim/image1.png';
 SiClickGoTo[0] = "";
 imgPath[0] = i0.src;
 i1 = new Image;
 i1.src = './images/anim/image2.png';
 SiClickGoTo[1] = "";
 imgPath[1] = i1.src;
 i2 = new Image;
 i2.src = './images/anim/image3.png';
 SiClickGoTo[2] = "";
 imgPath[2] = i2.src;
 i3 = new Image;
 i3.src = './images/anim/image4.png';
 SiClickGoTo[3] = "";
 imgPath[3] = i3.src;
 
 
 }
a = 0;
function ejs_img_fx(img)
 {
 if(img && img.filters && img.filters[0])
  {
  img.filters[0].apply();
  img.filters[0].play();
  }
 }
 
function StartAnim()
 {
 if (document.images)
  {
  document.write('<IMG  BORDER=2 ALT=Menu NAME=defil >');
  defilimg();
  }
 else
  {
  document.write('<IMG >')
  }
 }
function ImgDest()
 {
 document.location.href = SiClickGoTo[a-1];
 }
function defilimg()
 {
 if (a == 4)
  {
  a = 0;
  }
 if (document.images)
  {
  ejs_img_fx(document.defil)
  document.defil.src = imgPath[a];
  tempo3 = setTimeout("defilimg()",5000);
  a++;
  }
}
 
 
 
Ce script fonctionne trés bien mais je ne comprend pas a quel moment on récupére l'adresse de l'image à afficher.
J'éspére avoir été clair, merci d'avance de votre aide.

Reply

Marsh Posté le 31-03-2006 à 10:04:36   

Reply

Marsh Posté le 31-03-2006 à 10:45:56    

Les adresses des quatre images sont mises dans le tableau imgPath au début du code.
Puis, à chaque timeout, une adresse est affectée à l'objet contenant l'image par la ligne

document.defil.src = imgPath[a];

Reply

Marsh Posté le 31-03-2006 à 10:48:33    

Je ne comprend pas comment le script définit quelle image il doit afficher et comment il passe d'une image a l'aute

Reply

Marsh Posté le 31-03-2006 à 10:52:42    

L'objet image est créé par

document.write('<IMG  BORDER=2 ALT=Menu NAME=defil >');

Cet objet a pour nom "defil".
Cet objet IMG standard à une proriété nommée src, qui contient le chemin du nom de l'image. Lorsque cette propriété est changée, l'image est changée.

Reply

Marsh Posté le 31-03-2006 à 10:54:32    

ok je viens de compendre Merci

Reply

Marsh Posté le 31-03-2006 à 11:20:58    

Snif, pourquoi les gens continuent a copier-coller du code javascript tout pourri ?
On se croirai revenu 10 ans en arrière ..

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed