admin管理员组文章数量:1333160
Is there a general purpose solution for preserving dom state so that when a user returns to a page by using back/forward, the whole page is in the exact state that they left it?
This post asks and answers why the behavior is inconsistent with different browsers and different javascript libraries...
Ajax, back button and DOM updates
...but I am curious if anyone has a general solution to this problem that doesn't require reloading the page.
Is there a general purpose solution for preserving dom state so that when a user returns to a page by using back/forward, the whole page is in the exact state that they left it?
This post asks and answers why the behavior is inconsistent with different browsers and different javascript libraries...
Ajax, back button and DOM updates
...but I am curious if anyone has a general solution to this problem that doesn't require reloading the page.
Share Improve this question edited May 23, 2017 at 12:13 CommunityBot 11 silver badge asked Oct 15, 2009 at 15:51 PetePete 1,8102 gold badges20 silver badges31 bronze badges2 Answers
Reset to default 3I'm afraid there isn't, and there really can't be because we're talking about browser behavior that's pletely discretionary and not standards-defined. You could use Ajax to aggressively synchronize relevant DOM state to a session on a server, and always restore from that state on page load, but that will preserve the most recent state for that page, not the state that was necessarily present at a given desired point in the browser history.
You can use this cache busting technique in rails to make it work in modern browsers (chrome, ie8+, ff 3.5+). This worked for me on my last project when we had ajax update the dom and had to navigate back and have the ajax updates persist.
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
版权声明:本文标题:javascript - How do I preserve dom state in the browser history after dynamic dom manipulation? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742352229a2458723.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论