Results 1 to 5 of 5

Thread: Left-Right scrolling window script

  1. #1
    Join Date
    Jan 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Left-Right scrolling window script

    Hello All - I would like to edit this script so that it only scrolls from left to right once and then stops. Currently is scrolls, gets to the end, then returns back to the beginning and scroll again. Below is the script. Can anyone lend some assistance? Thanks, Dan

    <script language="JavaScript1.2">

    var speed=3
    var currentpos=0,alt=1,curpos1=0,curpos2=-1
    function initialize(){
    startit()
    }

    function iecompattest(){
    return (document.compatMode!="BackCompat")? document.documentElement : document.body
    }

    function scrollwindow(){
    if (document.all)
    temp=iecompattest().scrollLeft
    else
    temp=window.pageXOffset
    if (alt==0)
    alt=1
    else
    alt=0
    if (alt==0)
    curpos1=temp
    else
    curpos2=temp
    if (curpos1!=curpos2){
    if (document.all)
    currentpos=iecompattest().scrollLeft+speed
    else
    currentpos=window.pageXOffset+speed
    window.scroll(currentpos,0)
    }
    else{
    currentpos=0
    window.scroll(currentpos,0)
    }
    }
    function startit(){
    setInterval("scrollwindow()",10)
    }
    window.onload=initialize
    </script>

  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

    Not even the demo of this script seems to work very well for me. Do you have a demo page of your own that does what you want except for stopping when you want it to?

    PLEASE: Include the URL to your problematic webpage that you want help with.
    - John
    ________________________

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

  3. #3
    Join Date
    Jan 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your help! Below is the URL.

    http://www.loftusphoto.com/gallery.php

    Once you are on this page, select the Top, Right thumbnail (the one with the groom dipping the bride). This is the gallery I'm using as a test and it is working fine except it is repeating and I only want it to scroll across once.

    Thanks again for your help! - Dan

  4. #4
    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

    Well, that certainly looks much nicer! OK, you have two choices. #1 is what I think you say you want, is to stop at the end of one scroll. To do that , change this line:

    Code:
    setInterval("scrollwindow()",10)
    to:

    Code:
    scrollInt=setInterval("scrollwindow()",10)
    and these lines:

    Code:
    else{
    currentpos=0
    window.scroll(currentpos,0)
    }
    to:

    Code:
    else
    clearInterval(scrollInt)
    The other possibility would be to have it stop and return to the beginning. For that, the first line change is still used but the second change needs to end up looking like so:

    Code:
    else{
    clearInterval(scrollInt)
    currentpos=0
    window.scroll(currentpos,0)
    }
    - John
    ________________________

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

  5. #5
    Join Date
    Jan 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks, John...worked like a charm!

    Just read the standards notice so here is the info to the script in case anyone is interested:

    Left-Right scrolling window script
    http://www.dynamicdrive.com/dynamici...leftscroll.htm

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
  •