<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 3000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array();
// to add more images, just continue
// the pattern, adding to the array below
// 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=3)";
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);
}
// End -->
</script>
Can this be modified, or is there something else out there that might work.
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
With due respect to the original author, I have modified the original code to allow multiple slideshows to run. It was made possible by making the code object oriented.
My implementation for the timer for each slide does not look good. If you want, you can integrate this object-oriented timeout script found here.
Your script modification works wonderfully - it's just what I had in mind - thanks!!!
I'm playing around with timing and image sequence - I'll post the TEST page to my web site once I get it all figured out - I'll send you the link once it's posted.
Q: Do you know how I can improve the image fade-in/fade-out?
I am using the code kindly provided by glenngv but I would like to be able to have each image have its own link. I know next to nothing about java so I'd appreciate if someone could help me out by modifying glenngv's code or if gleengv is still around if you could do it for me please
I am using the code kindly provided by glenngv but I would like to be able to have each image have its own link. I know next to nothing about java so I'd appreciate if someone could help me out by modifying glenngv's code or if gleengv is still around if you could do it for me please
thankyou.
Try a script that separates functionality from content. Not only you can put any kind of mark-up in a slide, but it also becomes accessible to browsers with javascript disabled: www.klproductions.com/klslideshow.html
__________________ Vladdy | KL "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"
//sample usage
var slide1 = new SlideShow('SlideShow1',20000,3);
slide1.setPics("images/index/x8001.jpg","images/index/172x1.jpg","images/index/x61701.jpg","images/index/trade1.jpg");
var slide2 = new SlideShow('SlideShow2',20000,3);
slide2.setPics("images/index/x8002.jpg","images/index/172x2.jpg","images/index/x61702.jpg","images/index/trade2.jpg");
//if you want to start slideshows onload
window.onload = function(){
slide1.runSlideShow('slide1');
slide2.runSlideShow('slide2');
}
// End -->
</script><img name="SlideShow1" src="images/index/x8001.jpg"> <img name="SlideShow2" src="images/index/x8002.jpg">
i didnt take a good look at your script, but the a method will apply the link to the image itself, so if the script changes what images is displayed (not just the source, but the inner html entirely) you might want to use the div method, since that will apply the link to an 'invisible envelope' that's around anything between the tags, image or text or whatever.
and i believe script referenced above has a free evaluation download
You just can't make div as links like that.
THX, try this modified version:
Code:
<script type="text/javascript">
function SlideShow(imgName, speed, duration, makeLink){
var p; //length of Pic array
var j = 0;
var slide = imgName;
var me = this;
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = speed;
// Duration of crossfade (seconds)
var crossFadeDuration = duration;
var Pic = new Array();
this.timer = null;
this.setPics = function(){
var preLoad = new Array();
//set pics and preload
for (var i=0;i<arguments.length;i++){
Pic[i] = arguments[i];
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}
p = Pic.length;
if (makeLink){
//set onclick handler
document.images[slide].onclick=function(){
window.open(this.src,"_blank"); //opens in new window
//location.href=this.src; //use this instead if you want the image to open in the same window
}
//set cursor to make the image appear as link
document.images[slide].style.cursor=(document.all)?'hand':'pointer';
}
}
this.runSlideShow = function(){
var t;
if (document.all) {
document.images[slide].style.filter="blendTrans(duration=3)";
document.images[slide].style.filter="blendTrans(duration=crossFadeDuration)";
document.images[slide].filters.blendTrans.Apply();
}
document.images[slide].src = Pic[j];
if (document.all) {
document.images[slide].filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
this.timer = setTimeout(function(){me.runSlideShow()}, slideShowSpeed);
}
this.stopSlideShow = function(){
if (this.timer) clearTimeout(this.timer);
}
}
//end script
//sample usage
var slide1 = new SlideShow('SlideShow1', 20000, 3, true);
slide1.setPics("images/index/x8001.jpg","images/index/172x1.jpg","images/index/x61701.jpg","images/index/trade1.jpg");
var slide2 = new SlideShow('SlideShow2', 20000, 3, true);
slide2.setPics("images/index/x8002.jpg","images/index/172x2.jpg","images/index/x61702.jpg","images/index/trade2.jpg");
//if you want to start slideshows onload
window.onload = function(){
slide1.runSlideShow();
slide2.runSlideShow();
}
// End -->
</script>
...
<img name="SlideShow1" src="images/index/x8001.jpg"> <img name="SlideShow2" src="images/index/x8002.jpg">
I added a parameter in the SlideShow constructor to specify if image will be linked or not. I also modified the timer implementation.
Does not seem to work anymore? Also if I understand it correctly, you have simply modified it to make the picture a link rather then make each picture have its own individual link to another page.