Getting and save window scroll position with jQuery. You also need cookie plugin to store the position value in cookies, so it can be used after browser page changes.
Use this jQuery plugin for storing cookies. If you use it on your site then make sure you get the minified version.
Javascript Cookie Library with jQuery bindings and JSON support
Javascript Cookie Library with jQuery bindings and JSON support
If you press on a link that has link-class as class, then page scroll position remains the same on the next page you enter. It has to be your site, where our script is included.
Source code viewer
(function($){$().ready(function(){ $.cookies.get('myCookie'); // Set window scroll position if cookie is set. window.scroll(0, $.cookies.get('myCookie')); // Unset cookie after setting scroll position. $.cookies.del('myCookie'); // Make this class objects keep page scroll position. $('.link-class').each(function(){ $(this).click(function() { $.cookies.set('myCookie', getPageScroll()); }); }); });})(jQuery); // This function simply gets the window scroll position, works in all browsers. function getPageScroll() { var yScroll; if (self.pageYOffset) { yScroll = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop) { yScroll = document.documentElement.scrollTop; } else if (document.body) { yScroll = document.body.scrollTop; } return yScroll; }Programming Language: Javascript