views:

142

answers:

2

i am building a website which i am publishing in DIVs... when i refresh the page.. if the page was scrolled to position X... after page refresh when the page is loaded it will be at the same at scrolled to position X... i want to force page scrolled to top at page refresh...

  • what i can think of is of some JS / jQuery run as onLoad() function of page to SET the pages scroll to top... but i do not know the code for it...

  • a better option would be if there is some property etc to have the page loaded with its scroll position as default\top... which will be kind of like Page Load not Page Refresh

A: 

Check the jQuery .scrollTop() function here

It would look something like

$(document).load().scrollTop(0);
jon3laze
+1  A: 

You can do it using the scrollTop method on DOM ready:

$(document).ready(function(){
    $(this).scrollTop(0);
});
Pat