我可以设置页面的位置,而不实际刷新/重新加载它吗?
问题:
我可以设置页面的位置,而不实际刷新/重新加载它吗?
问题:
我的问题是页面是通过 get 变量 page.html?userid=12345 加载的。
关键是页面上可编辑的字段之一,并且提交使用 jQuery .post,因此页面地址永远不会改变。
但是,如果他们此时按下刷新,则该 url 将指向不存在的用户 ID。
我想将位置设置为 userid=12345,但没有实际检索该 URL(因为我想保留我的 jQuery 修改页面)。
这似乎存在安全/网络钓鱼风险,所以我怀疑这是不可能的。
Question:
Can I set the location of a page, without actually refreshing/reloading it?
Problem:
My problem is the page is loaded via a get variable page.html?userid=12345.
The key is one of the fields editable on the page, and the submit is using jQuery .post, so the page address never changes.
However, if they press refresh at this point, the url is pointing to a non-existent userid.
I want to set the location to userid=12345, but without actually retreiving that URL (cause I want to retain my jQuery modified page).
This seems like a security/phishing risk, so I suspect this is not possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不介意没有最好的浏览器支持并且域将匹配,请使用
history .pushState()
。If you don't mind not having the best browser support and the domain will match, use
history.pushState()
.