Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Scrollable content script III Quick back to top of scroll

  1. #1
    Join Date
    May 2008
    Posts
    91
    Thanks
    35
    Thanked 0 Times in 0 Posts

    Default Scrollable content script III Quick back to top of scroll

    1) Script Title: Scrollable content script III Very freely adapted from Scrollable content script II by jscheuer1
    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex11/scrollc2.htm
    3) Describe problem: I have constructed a lengthy scroll and want to place "back to top" points within the scroll. The normal <A> tag doesn't work, so I used a page refresh as a work around, but this is not effective. Can you help with a code modification that will get the scroll "back to top" from links within the code?
    http://www.rspsitedesign.com/Stowe/C...Tax_Forms.html

    Many thanks,
    Steve

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Just add this to the bottom of the content in the scroller:
    Code:
    <a href="javascript: void(0)" onclick="moveup()">Go Up</a>
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    printman55 (01-14-2009)

  4. #3
    Join Date
    May 2008
    Posts
    91
    Thanks
    35
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the suggestion.
    I added the code to the first "Top of Page" up arrow in the scroll, the last "Top of Page" up arrow in the scroll (bottom of content) and also below the Up-Down arrow controls at the bottom. Neither seems to work as intended??
    http://www.rspsitedesign.com/Stowe/C...Tax_Forms.html
    Steve

    Code added:
    <a href="javascript: void(0)" onclick="moveup()">Go Up</a>

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Change it to:
    Code:
    <a href="javascript: void(0)" onmouseover="movedown('topofpage', 6)">Go Up</a>
    Jeremy | jfein.net

  6. The Following User Says Thank You to Nile For This Useful Post:

    printman55 (01-14-2009)

  7. #5
    Join Date
    May 2008
    Posts
    91
    Thanks
    35
    Thanked 0 Times in 0 Posts

    Default

    I made the code change to the bottom of the content as you suggested. I also changed the page link to a test page:
    http://www.rspsitedesign.com/Stowe/C...orms-Test.html
    When you mouseover "Go To Top" it takes the scroll all the way to the bottom and then the up arrow control arrow doen't work?? What I'm looking for is a way to onclick get the scroll back to the top all at once.

  8. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Whoa.. that was the stupidest thing I've ever done:
    Code:
    <a href="javascript: void(0)" onclick="moveup('topofpage', 6)">Go Up</a>
    Jeremy | jfein.net

  9. The Following User Says Thank You to Nile For This Useful Post:

    printman55 (01-14-2009)

  10. #7
    Join Date
    May 2008
    Posts
    91
    Thanks
    35
    Thanked 0 Times in 0 Posts

    Default

    I't going in the right direction onclick. The problem is still that it still locks up the up/down arrow controls??

    http://www.rspsitedesign.com/Stowe/C...orms-Test.html

  11. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Right now I'm just trying to catch a fish out in the air.. But give this a try:
    Code:
    function moveup(id, speed){
    var crossobj=document.getElementById? document.getElementById(id) : document.all? document.all[id] : null;
    if (parseInt(crossobj.style.top)<=0){
    clearTimeout(moveupvar);
    }
    if (parseInt(crossobj.style.top)+speed<=0)
    crossobj.style.top=parseInt(crossobj.style.top)+speed+'px';
    moveupvar=setTimeout("moveup('"+id+"', "+speed+")",20);
    }
    Jeremy | jfein.net

  12. The Following User Says Thank You to Nile For This Useful Post:

    printman55 (01-14-2009)

  13. #9
    Join Date
    May 2008
    Posts
    91
    Thanks
    35
    Thanked 0 Times in 0 Posts

    Default

    Almost there!!
    Two things short of perfection. 1) Right after you click on the "Go Up" and wait until it gets to the top then mouse over the down arrow control, nothing happens. Then mouse over the up arrow then back to the down arrow is moves freely. Almost seems this process clears the lockup. 2) What speed would you suggest to zip the scroll back to the top fast?

  14. #10
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Try replacing the moveup, and the movedown functions with:
    Code:
    function movedown(id, speed){
    clearTimeout(moveupvar);
    var crossobj=document.getElementById? document.getElementById(id) : document.all? document.all[id] : null;
    var contentheight=crossobj.offsetHeight;
    if (parseInt(crossobj.style.top)-speed>=(contentheight*(-1)+crossobj.parentNode.offsetHeight-10))
    crossobj.style.top=parseInt(crossobj.style.top)-speed+'px';
    movedownvar=setTimeout("movedown('"+id+"', "+speed+")",20);
    }
     
    function moveup(id, speed){
    clearTimeout(movedownvar);
    var crossobj=document.getElementById? document.getElementById(id) : document.all? document.all[id] : null;
    if (parseInt(crossobj.style.top)<=0){
    clearTimeout(moveupvar);
    }
    if (parseInt(crossobj.style.top)+speed<=0)
    crossobj.style.top=parseInt(crossobj.style.top)+speed+'px';
    moveupvar=setTimeout("moveup('"+id+"', "+speed+")",20);
    }
    Jeremy | jfein.net

  15. The Following User Says Thank You to Nile For This Useful Post:

    printman55 (01-14-2009)

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
  •