Issue
i have a webpage that is full of div's with huge length, so whenever I refresh my page or manual document loading through actions, i need to scroll my window or document to same or previous position, but i want that to be done by browser automatically.
i searched it in web and found no help, but i came to know that solution is there with out any other lib inclusion.
I have a page of height more exceeds window height with some divs and select boxes whenever i select any thing in middle of page, it refresh my page and sends loads new document here i want to move to my previously selected select box placed div so that i can avoid manual scrolling on each selection
Solution
first i added position to localStorage
localStorage.setItem("scrollTop", document.body.scrollTop);
then getting same position from it onload(reload)
window.onload = function() {
var scroll = parseInt(localStorage.getItem("scrollTop"));
//parseInt(localStorage.scrollTop);
if (!isNaN(scroll))
document.body.scrollTop = scroll;
}
Answered By - gani
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.