Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to scroll browser view port to top of page after an ajax submit?

Tags:

jquery

I have an upload form -- after the user submits the form, I'd like to scroll the window back to the top of the page (where I display some help text). How do I correctly scroll the window back to the top of the page?

like image 271
rsturim Avatar asked Feb 01 '10 18:02

rsturim


1 Answers

You can use the scroll method on the window object to do this:

window.scroll(0,0)

The arguments are the horizontal and vertical measure of scrolling within the window, so 0,0 brings it back to the top.

like image 101
Dónal Boyle Avatar answered Oct 23 '22 23:10

Dónal Boyle