1

I'm having that annoying .scrollTop() not working problem. I'm trying to get the page to start at the top every time you hit the refresh button. To do this I added the $('html,body').scrollTop(0) to the $(document).ready. Works fine in Firefox but not in Chrome nor Safari. The scrollTop function works fine throughout the page (i.e. smooth scroll links), just not when you hit refresh on the page.

I am at a loss; tried different combos: $('html'), $('body'), $('html,body'), $(document) ,$(window)...

$(document).ready(function() {
    $('html,body').scrollTop(0);
})​;​
Core Xii
  • 6,270
  • 4
  • 31
  • 42
  • Are you on OS X? If so, have at look at this question: http://stackoverflow.com/q/13600832/149330 – int3 Nov 29 '12 at 07:47
  • http://stackoverflow.com/questions/1830080/jquery-scrolltop-doesnt-seem-to-work-in-safari-or-chrome-windows – Kevin Nov 29 '12 at 08:06

1 Answers1

2

If you don't need any animations, you could use the native JS function to do this instead of with jQuery. Just pass 0,0 and you'll be all right.

window.scrollTo(x-value, y-value);
MarcoK
  • 6,090
  • 2
  • 28
  • 40