如何停止Silverlight浏览器历史记录NavigationState/书签更改?
我们有一个 Silverlight Prism 项目,其复杂的状态信息存储在浏览器书签中。这使我们能够共享书签/链接,从而将应用程序恢复到完全相同的视觉状态。
然而,我们不希望微不足道的书签更改(即非导航更改)导致浏览器历史记录条目。否则,浏览器后退/前进按钮也会进行简单的更改(例如简单的列表选择、选项卡选择等)。
问:有没有办法仍然更改浏览器书签 URL,但将其从浏览器历史记录中排除,或者(如果失败)是否可以从浏览器历史记录中删除条目?
我们的视觉状态是优先考虑的,所以我们知道哪些实际上应该影响导航,哪些只是为了装饰。这可以在 URL 更改之前或之后确定,因此您的答案可以使用任一情况。我们可以在书签中添加一个特定的标记,表明它不应该被存档,如果这也有助于您的解决方案。
谢谢
We have a Silverlight Prism project with complex state information stored in the browser bookmark. This allows us to share bookmarks/links which will restore the application to the exact same visual state.
We do not however want trivial bookmark changes (i.e. non-navigation changes) to result in a browser history entry. Otherwise the browser back/forward buttons would also make simple changes (things like simple list selections, tab selections etc).
Q: Is there a way to still change the browser bookmark URL, but exclude it from the browser history, or (failing that) is it possible to remove entries from the browser history?
Our visual states are prioritised, so we know which ones actually should affect navigation and which are just for decoration. This can be determined either before the URL is changed or after, so your answer can use either situation. We can add a specific marker to the bookmark, indicating it should not be archived, if that would also help your solution.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己创建了一个答案,但不想依赖 JavaScript 功能。 我还需要检查所有浏览器是否支持 window.location.replace。
我现在用一个标志调用此方法,以表明我是否希望在浏览器历史记录中忽略书签:
然后添加此 JavaScript在 Silverlight 托管页面中:
有人需要更好的方法来做到这一点吗?
I created one answer myself, but would prefer not to rely on JavaScript features. I also need to check that window.location.replace is supported by all browsers.
I now call this method with a flag, to say if I want the bookmarking ignored in the browser history:
then add this JavaScript in the Silverlight hosting page:
Any takers for a better way to do this?