jScrollPane如何存储滚动位置?
我正在使用 JQuery 插件 jScrollPane。
一位客户问我,当用户滚动项目列表并单击其中一项,然后在浏览器中单击返回或从菜单返回到该页面时,滚动框是否可以位于相同位置。 :S
这意味着将插件计算的“top”css属性存储到mouseUp上的cookie中(当他们放开滑块时,存储“top”的值),然后当它们返回时,我可以检查该cookie并将其设置到该位置。
无论如何,这就是想法,我什至不知道从哪里开始。
感谢您的任何回复。 :)
I'm using the JQuery plugin jScrollPane.
A client has asked me if when a user scrolls the list of items, and clicks on one, then clicks back in their browser or goes back to that page from a menu, can the scroll box be at the same position. :S
This would mean storing the "top" css attribute computed by the plugin into a cookie on mouseUp (when they let go of the slider, store the value of "top") then when they return, I can check for that cookie and set it to that position.
That's the idea anyway, I've no idea even where to be begin with this.
Thanks for any responses. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我的解决方案。
滚动条的位置保存到 localstorage 中,然后当页面再次加载时,无论是通过刷新还是从另一个页面返回,如果 localstorage 的值大于 0 表示滚动条的顶部(默认,未滚动位置),则滚动条会滚动到那个位置。
Here's my solution.
The position of the scrollbar is saved to localstorage, then when the page loads again, either by refresh or back from another page, if localstorage has a value greater than 0 which represents the top of the scrollbar (default, unscrolled position), it scrolls to that position.