如何正确使用jquery出现插件
我已经使用jquery出现插件有一段时间了,但似乎我遇到了问题。
我现在就是这样做的。
我有一页长度不定。它是隐藏 SPAN 的列表,只有第一个可见。 HTML 从 OnAppear 事件处理程序加载到这些 SPAN 上。在同一事件处理程序中,我通过设置下一个 SPAN 的 style.display 属性使其可见。
一切都运行良好,除非出现以下情况。
假设用户已经向下滚动页面一段时间,并在上面积累了大量内容(由 OnAppear 事件处理程序加载)。他选择一个项目并打开详细视图,这是另一个页面。查看详细视图后,用户想要返回列表,并单击浏览器中的“返回”按钮。
浏览器尝试使用向下滚动的页面的缓存版本。 但是OnAppear加载的所有内容都丢失了。用户看到很长的空白页面的底部。
我的问题是:是否有使用 jquery Appear 插件的正确模式来很好地处理这种情况?
IE。当用户通过浏览器的“后退”按钮返回页面时,我希望用户看到一个包含已加载内容的 SPAN。如果用户从页面上的该位置向上或向下滚动,则会发生通常的 OnAppear 处理。
I have been using the jquery appear plugin for some time now, but it appears I have a problem.
This is how I do it at the moment.
I have a page of indefinite length. It is a list of hidden SPANs with only the first one visible. The HTML is loaded onto these SPANs from OnAppear event handler. In that same event handler I make the next SPAN visible by setting it's style.display property.
Everything works well except when the following senario arises.
Suppose the user have been scrolling page down for some time, and accumulated quite a bit of content on it (loaded by OnAppear event handler). He picks one item and opens a detailed view, and that's a different page. After looking at the detailed view the user wants to go back to the list, and clicks the BACK button in the browser.
The browser tries to use the cached version of the page scrolled a way down.
But all the content loaded by OnAppear is missing. The user sees the bottom of very long empty page.
My question is: is there a proper pattern for using the jquery Appear plugin to handle this situation nicely ?
Ie. when the user comes back to the page through Browser's BACK button, I want the user to see a single SPAN with content loaded in it. If the user scrolls UP or down from that position on the page, the usual OnAppear processing would take place.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议保存用户在会话中向下滚动到的位置或类似的位置,并使内容做出相应的反应。您将无法影响浏览器的行为,它将始终尝试重现用户上次所在的位置。
I'd suggest saving the position the user scrolled down to in the session or likewise and have the content react accordingly. You won't be able to influence that browser behavior, it will always try to reproduce the position the user was last at.