Skip to content

Instantly share code, notes, and snippets.

@rumblestrut
Created May 4, 2011 21:11
Show Gist options
  • Select an option

  • Save rumblestrut/956047 to your computer and use it in GitHub Desktop.

Select an option

Save rumblestrut/956047 to your computer and use it in GitHub Desktop.
Rotating images with javascript
Oh sure, you could do this with jQuery, but in my early days, this is what I used ...
<script>
<!--
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 8000
// 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] = '0.jpg';
Pic[1] = '1.jpg';
Pic[2] = '2.jpg';
// =======================================
// do not edit anything below this line
// =======================================
var Dummyt
var nCounterj = 0
var PicLen = Pic.length
var preLoad = new Array()
for (nCounteri = 0; nCounteri < PicLen; nCounteri++){
preLoad[nCounteri] = new Image()
preLoad[nCounteri].src = Pic[nCounteri]
}
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[nCounterj].src
if (document.all){
document.images.SlideShow.filters.blendTrans.Play()
}
nCounterj = nCounterj + 1
if (nCounterj > (PicLen-1)) nCounterj=0
Dummyt = setTimeout('runSlideShow()', slideShowSpeed)
}
</script>
-->
...
<img src="" name='SlideShow' alt="SlideShow">
<script>
runSlideShow();
</script>
</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment