Results 1 to 6 of 6

Thread: Left-Right Image Slideshow Script Double Loading

  1. #1
    Join Date
    Apr 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Left-Right Image Slideshow Script Double Loading

    1) Script Title: Left-Right Image Slideshow Script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ightslide2.htm

    3) Describe problem:

    Hello,

    I have been using this script for a while and only altering variables (I think). However when the page initially loads, the second image (slideimages[1]='<a href="http://www.clicknprint.com/" target="_blank"><img src="http://www.fairsandexpos.com/images/advertising/clicknprint.jpg" border=0"></a>') scrolls past twice. Then after the set has scrolled through the slideshow shows normally.

    Here's the script from my page if you need it:

    var scrollerwidth='150px'
    var scrollerheight='150px'
    var scrollerbgcolor='white'
    //3000 miliseconds=3 seconds
    var pausebetweenimages=3000


    //configure the below variable to change the images used in the slideshow. If you wish the images to be clickable, simply wrap the images with the appropriate <a> tag
    var slideimages=new Array()
    slideimages[0]='<a href="http://www.alliedspecialty.com/" target="_blank"><img src="http://www.fairsandexpos.com/images/advertising/allied.gif" border=0"></a>'
    slideimages[1]='<a href="http://www.clicknprint.com/" target="_blank"><img src="http://www.fairsandexpos.com/images/advertising/clicknprint.jpg" border=0"></a>'
    slideimages[2]='<a href="http://www.kandkinsurance.com/" target="_blank"><img src="http://www.fairsandexpos.com/images/advertising/KKInsuranceAd.jpg" border=0"></a>'
    slideimages[3]='<a href="http://www.hwins.com/" target="_blank"><img src="http://www.fairsandexpos.com/images/advertising/HaasWilkersonAd2.jpg" border=0"></a>'
    //extend this list

    ///////Do not edit pass this line///////////////////////

    var ie=document.all
    var dom=document.getElementById

    if (slideimages.length>1)
    i=1
    else
    i=0

    function move1(whichlayer){
    tlayer=eval(whichlayer)
    if (tlayer.left>0&&tlayer.left<=5){
    tlayer.left=0
    setTimeout("move1(tlayer)",pausebetweenimages)
    setTimeout("move2(document.main.document.second)",pausebetweenimages)
    return
    }
    if (tlayer.left>=tlayer.document.width*-1){
    tlayer.left-=5
    setTimeout("move1(tlayer)",50)
    }
    else{
    tlayer.left=parseInt(scrollerwidth)+5
    tlayer.document.write(slideimages[i])
    tlayer.document.close()
    if (i==slideimages.length-1)
    i=0
    else
    i++
    }
    }

    function move2(whichlayer){
    tlayer2=eval(whichlayer)
    if (tlayer2.left>0&&tlayer2.left<=5){
    tlayer2.left=0
    setTimeout("move2(tlayer2)",pausebetweenimages)
    setTimeout("move1(document.main.document.first)",pausebetweenimages)
    return
    }
    if (tlayer2.left>=tlayer2.document.width*-1){
    tlayer2.left-=5
    setTimeout("move2(tlayer2)",50)
    }
    else{
    tlayer2.left=parseInt(scrollerwidth)+5
    tlayer2.document.write(slideimages[i])
    tlayer2.document.close()
    if (i==slideimages.length-1)
    i=0
    else
    i++
    }
    }

    function move3(whichdiv){
    tdiv=eval(whichdiv)
    if (parseInt(tdiv.style.left)>0&&parseInt(tdiv.style.left)<=5){
    tdiv.style.left=0+"px"
    setTimeout("move3(tdiv)",pausebetweenimages)
    setTimeout("move4(scrollerdiv2)",pausebetweenimages)
    return
    }
    if (parseInt(tdiv.style.left)>=tdiv.offsetWidth*-1){
    tdiv.style.left=parseInt(tdiv.style.left)-5+"px"
    setTimeout("move3(tdiv)",50)
    }
    else{
    tdiv.style.left=scrollerwidth
    tdiv.innerHTML=slideimages[i]
    if (i==slideimages.length-1)
    i=0
    else
    i++
    }
    }

    function move4(whichdiv){
    tdiv2=eval(whichdiv)
    if (parseInt(tdiv2.style.left)>0&&parseInt(tdiv2.style.left)<=5){
    tdiv2.style.left=0+"px"
    setTimeout("move4(tdiv2)",pausebetweenimages)
    setTimeout("move3(scrollerdiv1)",pausebetweenimages)
    return
    }
    if (parseInt(tdiv2.style.left)>=tdiv2.offsetWidth*-1){
    tdiv2.style.left=parseInt(tdiv2.style.left)-5+"px"
    setTimeout("move4(scrollerdiv2)",50)
    }
    else{
    tdiv2.style.left=scrollerwidth
    tdiv2.innerHTML=slideimages[i]
    if (i==slideimages.length-1)
    i=0
    else
    i++
    }
    }

    function startscroll(){
    if (ie||dom){
    scrollerdiv1=ie? first2 : document.getElementById("first2")
    scrollerdiv2=ie? second2 : document.getElementById("second2")
    move3(scrollerdiv1)
    scrollerdiv2.style.left=scrollerwidth
    }
    else if (document.layers){
    document.main.visibility='show'
    move1(document.main.document.first)
    document.main.document.second.left=parseInt(scrollerwidth)+5
    document.main.document.second.visibility='show'
    }
    }

    </script>

    <ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor}; visibility=hide>
    <layer id="first" left=1 top=0 width=&{scrollerwidth}; >
    <script language="JavaScript1.2">
    if (document.layers)
    document.write(slideimages[0])
    </script>
    </layer>
    <layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>
    <script language="JavaScript1.2">
    if (document.layers)
    document.write(slideimages[1])
    </script>
    </layer>
    </ilayer>

    <script language="JavaScript1.2">
    if (ie||dom){
    document.writeln('<div id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden;background-color:'+scrollerbgcolor+'">')
    document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0px;top:0px">')
    document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:1px;top:0px;">')
    document.write(slideimages[0])
    document.writeln('</div>')
    document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:0px">')
    document.write(slideimages[1])
    document.writeln('</div>')
    document.writeln('</div>')
    document.writeln('</div>')
    }
    </script>


    Thanks for any help you can give.
    Last edited by bkist; 04-01-2008 at 04:20 PM. Reason: Hit enter before I wanted to submit

  2. #2
    Join Date
    Aug 2004
    Posts
    9,890
    Thanks
    3
    Thanked 964 Times in 953 Posts
    Blog Entries
    15

    Default

    Everything looks fine. Do you have a link to the problem page?

  3. #3
    Join Date
    Apr 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by ddadmin View Post
    Everything looks fine. Do you have a link to the problem page?
    http://www.fairsandexpos.com/

    Notice that the ClickNPrint Tickets ad scrolls twice before setting in proper order. Thanks for your help.

  4. #4
    Join Date
    Apr 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Any ideas? Might there be something else on the page that causes this occurrence?

  5. #5
    Join Date
    Aug 2004
    Posts
    9,890
    Thanks
    3
    Thanked 964 Times in 953 Posts
    Blog Entries
    15

    Default

    Looks like a bug in the script. If so though, I can't believe why it was never brought up by someone else all this time. Try changing the below inside the script, specifically, the part in red:

    Code:
    if (slideimages.length>1)
    i=2
    The part in red is the modified value (original is 1).

  6. #6
    Join Date
    Apr 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It seems to have worked. Thank you so much for your help.

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
  •