PDA

View Full Version : a js error in fade-in slideshow



mocax
02-10-2009, 02:42 PM
1) Script Title: Ultimate Fade-In Slideshow

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm

3) Describe problem:
I get this js error in firefox "this.theimages[picindex] is undefined" and similar one in IE, whenever the images array is of size 1.

It happens on the line


if (this.theimages[picindex][1]!="") //if associated link exists for image

my site retrieves a list of images from the database and output them as, for example


<script type='text/javascript'>
var slides = new Array()
slides[0]=['http://i43.tinypic.com/2mgpch3.jpg', '', '']
slides[1]=['http://i41.tinypic.com/vgsapj.jpg', '', '']
new fadeshow(slides, 800, 600, 0, 3000, 1)
</script>

however, sometimes the database only has a single image available and the server generates the following


<script type='text/javascript'>
var slides = new Array()
slides[0]=['http://i43.tinypic.com/2mgpch3.jpg', '', '']
new fadeshow(slides, 800, 600, 0, 3000, 1)
</script>
this is the case when it gets the error.

jscheuer1
02-10-2009, 02:52 PM
Make the following modification to the main script function:


. . . bgcolor="white"

////NO need to edit beyond here/////////////

var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers

var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all

function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
if (theimages.length == 1);
theimages[1] = [theimages[0][0], theimages[0][1], theimages[0][2]];
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0 . . .

dixittejas
07-20-2011, 07:44 AM
Remove ';' after if statement

Add like this:

if (theimages.length == 1)
theimages[1] = [theimages[0][0], theimages[0][1], theimages[0][2]];

Thanks