Results 1 to 3 of 3

Thread: a js error in fade-in slideshow

  1. #1
    Join Date
    Feb 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default a js error in fade-in slideshow

    1) Script Title: Ultimate Fade-In Slideshow

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...nslideshow.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

    Code:
    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

    Code:
    <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

    Code:
    <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.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Make the following modification to the main script function:

    Code:
    . . . 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 . . .
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Remove ';' after if statement

    Add like this:

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

    Thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •