Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Nov 2011
    Posts
    154
    Thanks
    5
    Thanked 0 Times in 0 Posts

    always start at top on page refresh?

    Hello, I came across a page the other day, that would automatically scroll you to the top of the page after refreshing, if you happened to be scrolled down some prior to refreshing. Could anyone explain how I can accomplish this?

  • #2
    New Coder
    Join Date
    Mar 2012
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post
    Code:
    $(document).ready(function(){
        $(this).scrollTop(0);
    });
    **You will have to link to jQuery to make this work**
    Last edited by chrisf; 05-30-2012 at 05:18 PM.

  • #3
    Regular Coder
    Join Date
    Nov 2011
    Posts
    154
    Thanks
    5
    Thanked 0 Times in 0 Posts
    It didn't work for me. When I scroll down the page and then refresh, the page stays scrolled down. I just need to place that code within <script></script> inside the header? I have linked to jQuery.

  • #4
    New Coder
    Join Date
    Mar 2012
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by resin View Post
    It didn't work for me. When I scroll down the page and then refresh, the page stays scrolled down. I just need to place that code within <script></script> inside the header? I have linked to jQuery.
    I would recommend putting the script at the end of the page before the closing body tags.

  • #5
    Regular Coder
    Join Date
    Nov 2011
    Posts
    154
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Ok so it look like your code does work for Firefox, but not IE. Is there some additional code to make it work in IE? Here is a great example that works in IE- http://www.talentgarden.it/it/#!/home . Scroll down that page some, and then refresh. It will automatically start you back at the top. This is exactly what I need.
    Last edited by resin; 05-31-2012 at 09:45 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •