0

We have a site where when a link is clicked the new page that loads doesn't scroll to the top. I had a developer do this site. Would like to know if I can fix this quick in the JS or somewhere.

heres the site http://nisbetplantation.com/#/

try clicking one of the thumbnails in the bottom.

Travis Collins
  • 3,982
  • 3
  • 31
  • 44
  • It works fine for me. Also, try to include the essential code here, as only a link to a website is not very useful to others, especially if the website changes or disappears. – Jonas Czech Apr 28 '15 at 17:02
  • The top links work fine. its any link in the bottom. i think its scrolls to the exact position from where it was clicked. – Harshad Methrath Apr 28 '15 at 17:29
  • The 3 links on the thumbnails at the bottom "101 things to do"... Work fine for me, the next page starts off scrolled to the top. – Jonas Czech Apr 28 '15 at 17:32
  • They do in chrome. But other browsers they don't. Sorry I should have mentioned that. – Harshad Methrath Apr 28 '15 at 17:34
  • I'm not actually sure why. Must be some Chrome-specific thing. – Jonas Czech Apr 28 '15 at 18:08
  • possible duplicate of [Changing route doesn't scroll to top in the new page](http://stackoverflow.com/questions/21055952/changing-route-doesnt-scroll-to-top-in-the-new-page) – Travis Collins May 05 '15 at 12:13

1 Answers1

0

I had this problem as well. I solved it with this code, which scrolls to the top of the page any time a state change occurs.

    $scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){
        $window.scrollTo(0, 0);
    });
Travis Collins
  • 3,982
  • 3
  • 31
  • 44
  • I just took a look at your code. You're not actually using ui-router, you're using ngRoute. I'll edit your question to fix the incorrect tag. You will need to change my code to the event that fires when ngRoute is done changing routes. Sorry I'm not familiar enough with it to know what that event is. – Travis Collins May 04 '15 at 11:27
  • window.scrollTo(0, 0); Travis this fixed it actually. Thank you very much – Harshad Methrath May 05 '15 at 13:23