slideshow js

Invité
Invité n'ayant pas de compte PHPfrance

17 sept. 2006, 17:26

Bonjour à tous,
j'ai récupéré le code suivant pour réaliser un slideshow en javascript. Il marche bien mais les images sont trop petites.
Ou dois-je ajouter des attributs width et height pour modifier la taille des images? Je ne vois rien qui parle de la taille dans le code!
Step 1.
Put the following script in the head of your page:

<script>

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = '1.jpg'
Pic[1] = '2.jpg'
Pic[2] = '3.jpg'
Pic[3] = '4.jpg'
Pic[4] = '5.jpg'

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[j].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)
}
</script>

===========================================================

Step 2.
Put this onload event call in your body tag:
  
<body onload="runSlideShow()">  

===========================================================

Step 3.
Put this in the body of your page where you want the 
slide show to appear.  

Set widths and heights same as images
Set image file same as first image in array Pic[] (above)

<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="VU" height=150 width=150>
<img src="1.jpg" name='SlideShow' width=150 height=150></td>
</tr>
</table>

===========================================================

Invité
Invité n'ayant pas de compte PHPfrance

17 sept. 2006, 17:48

je précise que redimensionner le tableau html qui est en étape 3 n'a aucun effet sur les images.

Modérateur PHPfrance
Modérateur PHPfrance | 7636 Messages

17 sept. 2006, 18:07

Salut,
regarde cette ligne :
<img src="1.jpg" name='SlideShow' width=150 height=150>
Si tu supprime quel est le résultat.

/!\ Avant de poster se documenter et rechercher.
Qui ne sait pas rendre un service n'a pas le droit d'en demander.
MaBrute

Invité
Invité n'ayant pas de compte PHPfrance

17 sept. 2006, 18:25

ça marche, j'avais pas vu ça. merci!