像 jQuery mobile 一样更新 URL

发布于 2024-12-11 19:37:57 字数 99 浏览 1 评论 0原文

jQuery mobile 使用什么方法来更新 URL,而无需浏览器重新导航到该 URL?也就是说,如何在不更改页面及其 DOM 的情况下编辑 url 字符串并保持在完全相同的页面上?

What methods does jQuery mobile use to update the URL without having the browser re-navigate to that URL? That is, how can I just edit the url string without altering the page and it's DOM and stay on the exact same page?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静谧幽蓝 2024-12-18 19:37:57

jQuery 使用 HTML5 中存在的一些新的历史对象方法。

来自火狐

HTML5引入了history.pushState()和history.replaceState()方法,它们分别允许您添加和修改历史记录条目。这些方法与 window.onpopstate 事件结合使用。

您可以在这里阅读更多相关内容。 https://developer.mozilla.org/en/DOM/Manipulated_the_browser_history

jQuery uses some new history object methods that are present in HTML5.

from mozilla

HTML5 introduced the history.pushState() and history.replaceState() methods, which allow you to add and modify history entries, respectively. These methods work in conjunction with the window.onpopstate event.

You can read up more on it here. https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文