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

Thread: jquery scroll to top control

  1. #1
    Join Date
    Sep 2014
    Location
    Australia
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default jquery scroll to top control

    1) Script Title: jquery scroll to top control

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

    3) Describe problem: I've installed the jquery scroll to top control from Dynamic Drive and everything works except the image doesn't appear on the page.
    The link is there and when I hover over where the image should be the text comes up "scroll back to top", I click and the page scrolls to the top. I've tried placing my image in various directories, but have had no joy. Any ideas??

    I've only put the scroll to top control on one page so far and that page is http://navyvic.net/vale/vale.html
    The image should be in the bottom right hand corner.

    I've been using dd scripts for a few years and if I've had a problem I've been able to sort it out in my amateurish way. But I can't see what's wrong here.
    Last edited by ozetigerman; 09-02-2014 at 04:27 AM.

  2. #2
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    512
    Thanks
    9
    Thanked 61 Times in 59 Posts

    Default

    Ummm fyi you have:
    opacity:0;
    change that to
    opacity:1;
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

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

    When I look at your page, I notice it doesn't scroll like some others. I think that's the problem. Add this to a stylesheet:

    Code:
    #topcontrol {opacity: 1 !important;}
    That should enable you to see the image all the time. For the setup on that page, the script may or may not be able to be edited to have the image hidden at certain scroll states.
    - John
    ________________________

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

  4. #4
    Join Date
    Sep 2014
    Location
    Australia
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks mate. But it didn't work. John's solution below has worked though, even though it doesn't fade in and out.

    Thanks for help.

  5. #5
    Join Date
    Sep 2014
    Location
    Australia
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks John,

    Yes, that works but it doesn't fade in and out. Will have to be satisfied. Tried changing the opacity in the .js file but that didn't work.

    Will have to be satisfied with the image on the page permanently.

    Thanks for your help.

  6. #6
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    512
    Thanks
    9
    Thanked 61 Times in 59 Posts

    Default

    I kinda remade it but here is a simple version:
    JQuery:
    Code:
    $(function(){
    	scrollup({
    		id: 'autoup',
    		image: 'up.png',
    		display: 100,
    		fadeduration: [300, 300, 300] //fade in, fade out, scroll time
    	})
    })
    
    function scrollup(a){
    	var html = '<div id="'+a.id+'"><img src="'+a.image+'" \/></div>'
    	$(html).appendTo('body');
    	
    	
    	$(document).on('scroll',window, function(){
    		if($(this).scrollTop() >= a.display)
    			$('#'+a.id).fadeIn(a.fadeduration[0]);
    		else
    			$('#'+a.id).fadeOut(a.fadeduration[1]);
    	})
    	
    	
    	$(document).on('click','#'+a.id,function(){
    		$("body,html").animate({scrollTop: 0}, a.fadeduration[2]);
    	})
    }
    CSS:
    Code:
    #autoup { position:fixed; right:10px; bottom:5px; cursor:pointer; display:none;}
    Updated and you still do not need anything in the body.

    Please notice that the id in the scrollup function matches the id in the css
    Last edited by Deadweight; 09-02-2014 at 02:24 PM.
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

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

    The problem here is that due to its layout, on the example page, neither the $(window), nor the $('html') objects appear to register any scrolling action. At least not in Opera, I'm not sure about others. The script only registers whether or not to show the button as a consequence of the scroll state of the $(window) object, which is always 0 in this case. The event which triggers this inquiry is the $(window) object's on scroll event (on resize also). But since the scroll event never happens, even if triggered via resize, the scroll state would still be 0 - below the threshold to reveal the button. All this could be changed to use the $('body'), which does register scroll on this page, but it might not be cross browser. Again, the limitation first arises because of the page's somewhat unique layout.
    - John
    ________________________

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

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

    Things are further complicated on the page because it's also running a prototype/scriptaculous version of lightbox. That's throwing errors such that even if we used the body's scroll state, it still might not reveal the image. The page doesn't appear to be using the lightbox script, so that could be removed. If other, similar pages are using it though, jQuery and the scroll to top script could be run in no conflict mode. But that doesn't always work. A jQuery lightbox type script could be used instead, then one could get rid of prototype/scriptaculous. For now, unless you want to try at least some script changes, and perhaps a lot of changes, I'd just leave it be. At least it's working.
    - John
    ________________________

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

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

    OK, this will actually be easy if you want to fix it and you don't need the lightbox (which is an older outdated version that you don't appear to be using anyway). Just get rid of this (from the page's source code):

    Code:
    <script type="text/javascript" src="../js/prototype.js"></script>
    <script type="text/javascript" src="../js/scriptaculous.js?load=effects"></script>
    <script type="text/javascript" src="../js/lightbox.js"></script>
    <link rel="stylesheet" href="../css/lightbox.css" type="text/css" media="screen" />
    If you do need a lightbox for other pages, use a jQuery based one like Slimbox2 or Fancybox.
    - John
    ________________________

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

  10. #10
    Join Date
    Sep 2014
    Location
    Australia
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    DW & John,

    Thanks for your help, now I'm totally confused. It gets a bit much for an old man like me.

    Will take the time to understand and try the ideas out. It's funny that it's working on other pages but at the moment I'm unable to upload them because I'm getting a 552 disc full error. Need to contact my ISP

    Thanks for your help again
    Laurie

Similar Threads

  1. Hover state for 'jQuery Scroll to Top Control' script
    By stinkystink in forum Dynamic Drive scripts help
    Replies: 6
    Last Post: 11-10-2012, 04:28 PM
  2. jQuery Scroll to Top Control for custom links
    By sylver in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 02-16-2012, 08:12 AM
  3. jQuery Scroll to Top Control
    By pookeyblow in forum Dynamic Drive scripts help
    Replies: 10
    Last Post: 09-17-2011, 07:13 AM
  4. jQuery Scroll to Top Control doesn't work >.<
    By Emeralda in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 06-26-2011, 09:51 AM
  5. jQuery Scroll to Top Control v1.1 Error
    By quddusaliquddus in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 06-30-2009, 05:13 AM

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
  •