浏览器会自动删除URL中的#吗?
我们的前端人员需要形成一个包含哈希值的网址(即 http://blah/#some-link.) 当我们在浏览器上点击这个并使用 fiddler 检查 http 流量时,我们看到 blah/ 之后的所有内容都被删除了,所以请求实际上只是 http://blah/。我们还在我们的服务器 eclipse 调试日志中确认了这一点。
请求被 Spring security 重定向到正确的登录页面(因为用户尚未登录),但浏览器上的 url 现在显示: http://blah/some-link (哈希值已被删除),但浏览器上的网址实际上应该是 < a href="http://blah/log-in" rel="nofollow">http://blah/log-in。
知道这是为什么吗?有什么修复或解决方法吗?提前致谢。
our front end guy needs to form a url containing the hash, (i.e, http://blah/#some-link.) when we hit this on the browser and inspect the http traffic using fiddler, we saw that everything after blah/ gets removed, so the request is really just http://blah/. we also confirmed this on our server eclipse debug log.
the request gets redirected to the correct login page by Spring security(because user hasn't logged in), but the url on the browser now shows:
http://blah/some-link (the hash got removed) but the url on the browser should really be http://blah/log-in.
any idea why this is? any fix or workaround? thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
#
之后的 URI 部分称为片段
:URI = schema ":" hier-part [ "?" query ] [ "#"fragment ]
schema 和 hier-part 标识文档的位置,fragment 帮助浏览器标识文档内部的位置。
片段在作为请求的一部分发送之前由客户端软件从 URI 中剥离。
来自 RFC3986:
URI part after
#
is called afragment
:URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
Scheme and hier-part identify the location of a document, and fragment helps the browser to identify a location inside this document.
Fragment is stripped from URI by client software before it is sent as a part of request.
From RFC3986:
根据 HTTP 规范,
#
后面的内容仅在客户端使用。如果您需要在服务器上提供该信息,则可以使用不同的分隔符,也可以在页面加载后通过 ajax 提交,并在客户端上使用 javascript 读取该信息。Content after the
#
is only used on the client side, per HTTP specification. If you require that information on the server, you can either use a different separator, or you can submit it via ajax after the page has loaded by reading it on the client with javascript.你可以用 JavaScript 来做到这一点
you can do this with javascript
包含哈希值 (#) 及其之后的 URI 部分永远不会作为 HTTP 请求的一部分发送到服务器。
原因是哈希标识符最初设计为指向给定网页内的引用,而不是服务器上的新资源。
如果您想获取哈希标识符,则必须使用一些客户端 JavaScript 来获取该值并将其与表单一起提交。
The part of the URI including and after the hash (#) is never sent to the server as part of the HTTP request.
The reason is that the hash identifier was originally designed to point at references within the given web page and not to new resources on the server.
If you want to get the hash identifier, you'll have to use some client-side JavaScript to grab the value and submit it with the form.
在 IE9、IE10 或 IE11 中单击后退按钮时,哈希标记将从 URL 中删除
在 IE10 中,第一次单击 HREF 链接会导致以下正确的 url:
http://www.example.com/yy/zz/ff/ paul.html#20007_14
如果再次单击后退按钮,则会出现以下网址:
http://www.example.com/yy/zz/ff/paul。 html
解决方案:
请将 url 更改为 https
它对我有用
Hashmark is removed from URL when the back button is clicked in IE9, IE10 or IE11
In IE10 , first time on clicking the HREF link leads to the correct below url:
http://www.example.com/yy/zz/ff/paul.html#20007_14
If back button is clicked again the, then it comes to the below url:
http://www.example.com/yy/zz/ff/paul.html
Solution :
Please change the url with https
It works for me