I am submitting some data to my database then reloading the same page as the user was just on, I was wondering if there is a way to remember the scroll position the user was just on?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I realized that I had missed the important part of submitting, so, I decided to tweak the code to store the cookie on click event instead of the original way of storing it while scrolling.
Here’s a jquery way of doing it:
jsfiddle ( Just add
/showat the end of the url if you want to view it outside the frames )Very importantly, you’ll need the jquery cookie plugin.
jQuery:
Here’s still the code from the original answer:
jsfiddle
jQuery:
@Cody’s answer reminded me of something important.
I only made it to check and scroll to the position vertically.