View Full Version : Minor issue with jQuery Scroll to Top Control v1.1

M.D. Roche
04-28-2015, 12:10 AM
1) Script Title: jQuery Scroll to Top Control v1.1

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex3/scrolltop.htm

3) Describe problem: I've noticed that the "scroll up" link is always present on the page, even when the arrow image is hidden. When I'm all the way at the top of the page and the image is hidden, the link is still there and I'm able to click it. Is there any way to make the link completely vanish when it's not visible, instead of just hiding the image?

04-28-2015, 12:46 AM
Using a text only editor like Notepad, open the scrolltopcontrol.js script and replace the function of the same name with this one (additions highlighted):

var scrolltop=jQuery(window).scrollTop()
if (!this.cssfixedsupport)
this.state.shouldvisible=(scrolltop>=this.setting.startline)? true : false
if (this.state.shouldvisible && !this.state.isvisible){
this.$control.stop().css({visibility: 'visible'}).animate({opacity:1}, this.setting.fadeduration[0])
else if (this.state.shouldvisible==false && this.state.isvisible){
this.$control.stop().animate({opacity:0}, this.setting.fadeduration[1], function(){this.style.visibility = 'hidden';})

Save changes and use that version. The browser cache may need to be cleared and/or the page refreshed to see changes.

04-28-2015, 12:48 AM
Post your html code for the page in question or a link to it.
The arrow isn't supposed to show until you scroll 100px down the page.


M.D. Roche
04-28-2015, 01:22 AM
That code didn't entirely correct the problem.

Go here, make sure you're scrolled all the way up so that the button is hidden (don't scroll down after the page has loaded), and put your cursor over the bottom right part of the page where it would normally be. Your cursor and the "SCROLL UP" message shows that a link is still there, even though the button isn't visible.

I noticed that the problem is corrected after you've scrolled down and back up again, but I want the link to be completely gone when the page is loaded.


M.D. Roche
04-28-2015, 01:39 AM

I altered this tiny part of the code and it works perfectly now.

.css({position:mainobj.cssfixedsupport? 'fixed' : 'absolute', bottom:mainobj.controlattrs.offsety, right:mainobj.controlattrs.offsetx, visibility:'hidden', opacity:0, cursor:'pointer'})

Thanks for your help.

04-28-2015, 02:29 AM
Sure! Funny, I was thinking it might need something like that, but on the demo page it was initially seen even with the page at its top, so I thought - maybe not.