Reputation: 43
I want to get the (vertical and horizontal) scrollbar positions from a loaded html page. Then after making a backend task (e. G. deleting operation) i want to reload the page and set the old positions from scrollbar.
So how can i make this with jquery? (Getting scrollbar positions and setting it later again) I use jquery 1.8.3 at the moment. I tried some ideas, but nothing worked really.
Thanxs for your answers.
Upvotes: 1
Views: 386
Reputation: 2493
Use
window.onscroll = function (oEvent) {
// called when the window is scrolled.
}
and
// get scroll position
var x = window.scrollX,
y = window.scrollY;
for get scroll position, then save x and y to cookie. After refresh read them from cookie and use code to set scroll position:
window.scrollTo( x, y );
Upvotes: 1