I've seen a tonne of great web apps with this annoying quirk: When you press save or OK on a settings page, it jumps back to the top as the page reloads. Even some high profile products like Gmail have this irritating usability issue. (Try merging 2 contacts at the bottom of your list and watch the list jump back to the top)
This little bit of javascript saves a cookie when the page is unloaded and attempts to read it and set the scroll position the next time the page is loaded.
Implementation is a cinch:
THE FILE: (Please see right hand pane before download!)
http://www.crondesign.com/projects/downloads/scrollfix.js
IN HEAD:
<script src="scrollfix.js" type="text/javascript"></script>
BODY TAG:
<body onunload="unloadP('UniquePageNameHereScroll')" onload="loadP('UniquePageNameHereScroll')">
I love you! there are so many messy, confusing, ugly suggested solutions for this issues that end up not working at all.
ReplyDeletethis is clean, easy, and .... IT WORKS!
Awesome script, but when I click on a link on my site it automatically scrolls down as far as I was on the previous page.
ReplyDeleteAny idea how to fix this minor bug?
Thanks in advance...
Hi Mitch, you need to keep the page names unique or it will read the cookie from the previous page!
ReplyDeleteGreat!!!
ReplyDeleteThanks a lot.
ReplyDeleteSince 2009 and your post is still very useful.
It resolved a big problem.
Another big thank from 2012.
ReplyDeletegreat job. This helped out alot with our old classic asp application.
ReplyDeleteThanks Thanks Thanks Thanks Thanks
ReplyDeleteNice one....
ReplyDeleteonly problem is it uses BODY TAG.
ReplyDeletecan you make code without it.
@spilpoker Try:
ReplyDeletewindow.onunload = function(){
unloadP('UniquePageNameHereScroll')
}
thank you for your reply
ReplyDeleteadded your code to the bottom of the scrollfix.js script don´t know if it work cause only have the scroll problem in,internet explore, tested in ie 8 and 9
and have tried lots of other scripts no one works
so maybe i cant be done in those browsers.
Like a charm! Thank you! :)
ReplyDeleteThis is awesome, thank you so much.
ReplyDeleteAwesome that did the trick, had some probs with refreshing iframes, that i would love to if they could remember their scroll positions and this defenetly is doing the trick
ReplyDeleteThanks again
Great solution! However it's not working for me on iOS (Mobile Safari.) Any tips on making it work with that?
ReplyDeleteThanks!
After wasting couple hours testing other solutions, finally I got here. Works perfectly.
ReplyDeleteDoesn't work on mobile safari
ReplyDeleteWhat a brilliant article, thank you so much for that... Cos I've spent searching for that topic on Google for nearly two days! None of these helps, so this one helps me alot, THANK YOU!
ReplyDeleteIt Works perfectly. Thank You.
ReplyDeleteGreat Job Man!!
ReplyDeleteSo great. I have searched the solution for several days.
ReplyDeleteThank you so much!
wow!!!!great
ReplyDeleteI'm sorry but I can't get it to work. Probably because I'm very new to web development and not sure what I am doing.
ReplyDeleteI have a very wide picture in a div with horizontal scroll. The picture has hot spots to other pages.
On return I would like to be where I was originally.
I note the js file is called fixscroll.js but the script in the head calls for scrollfix.js.
Also what is the unique page name? Name of the HTML page or the jpg image
I hope you can help
Chris
Great stuff! Thanks!!
ReplyDeletethxxxxxxxxxxx u a lot, i searched this for a long time
ReplyDeleteanothor thanks from 2015 :D
Hi
ReplyDeleteDoes this solution work with Classic ASP. Thanks.
David
This comment has been removed by the author.
ReplyDeleteThank you very much.. this code really helped me!!
ReplyDeletethank you... it help much..
ReplyDeleteJust found this post by chance. Tested the code and all great - thanks.
ReplyDeleteThis is very good script. you are perfect. thank you!!
ReplyDeleteHi there. I'm using php to include the page that I want to remember scroll position for. Basically, there is a vertical scrolling page with images which navigate to individual pages for those images. Each of the image pages includes the same vertical image menu. I am this close to just using a wordpress gallery plugin, but wondering if your script could work for my situation? Thanks!
ReplyDeleteHi, thanks, your script works in new browsers almost 9 years after your publication, it's great!!!
ReplyDeleteI can only agree with all the positive comments above! So simple and so useful for my classic ASP site - thank you!
ReplyDeleteKanhasoft is the PHP Application Development Company based in India and USA. We are promoting business services across USA, UK, Japan, Canada, Singapore, Australia, Sweden, Norway, Switzerland, New Zealand, Germany, South Africa and 45 more.
ReplyDeletehttps://ifreegiveaways.net/hack-twitter-account/
ReplyDeleteIts as if you had a great grasp on the subject matter, but you forgot to include your readers. Perhaps you should think about this from more than one angle. To find The 8 Best Things to Do in Playa Maderas, Nicaragua Please go with site things to do
ReplyDeleteIs it suppose to show the top of the page first then jump to the last scroll position? or I am doing something wrong. help
ReplyDeleteprovides top quality vinyl wraps
ReplyDeleteonly problem is it uses BODY TAG.
ReplyDeletecan you make code without it. The top Santa Ana Trucking Company
best replica designer bags x49 d4z08c2n86 aaa replica bags e78 z3w88u5x39 gucci replica handbags j84 t1t92t5j34
ReplyDeleteUnemployment and lowered client discretionary income also remain key challenges to 강원랜드 쪽박걸 a speedy recovery. Also, since a big amount of cash spent on gambling is attributed to fit machines at areas such as motels and airports, the closures of airports and motels is affecting revenue era from these areas. Security and the safety of gamblers’ details remain probably the most discussed.
ReplyDelete