或许你称它为尖锐 - #符号。
Or maybe you call it "sharp" - the # symbol.
我遇到过一个实例,其中#!和#在一个URL中同时使用。通过阅读其他文章,包括RFC,我无法理解这是否是合法的组合。当遇到这样的页面时,Mozilla浏览器(在这种情况下为Iceweasel)将URL显示为2#,而Chrome只显示一个,但不久之后就会死亡(包含页面的选项卡变得无响应并崩溃 - 但可能无法连接) 。
I've came across one instance, where #! and # used simultaneously in a single URL. From reading other articles, including RFC, I can't understand whether that is a legal combination or not. When encountering such page Mozilla browser (Iceweasel in this case) displays the URL as having 2 #'s, while Chrome displays only one, but dies shortly afterwards (the tab containing the page becomes unresponsive and crashes - but it may not be connected).
现在,我的问题是,在一个URL中同时使用它们是合法的还是冗余的(应该规范化),还是仅仅是一个bug在Mozilla浏览器中?所以,假设我正在制作一个AJAX请求,或试图浏览浏览器历史记录 - 如果我遇到这种情况,该怎么办?
Now, my question is, is it legal to have both in one URL, is it maybe legal and redundant (should be normalized), or is it just a bug in Mozilla browser? So, suppose I'm making an AJAX request, or trying to navigate the browser history - what should I do, if I encounter this situation?
RFC-3986: tools.ietf/html/rfc3986#section-3.4 ,应该澄清一下......以防万一。
RFC-3986: tools.ietf/html/rfc3986#section-3.4 , which should be clarifying it... just in case.
此外: developers.google/webmasters/ajax-crawling/docs/specification Google抓取工具如何查看内容。
Also: developers.google/webmasters/ajax-crawling/docs/specification how Google crawlers see things.
推荐答案片段的格式只允许斜杠,问号和 pchar s。如果你查找RFC,你会发现哈希标记不是有效的 pchar 。
The format for a fragment only allows slashes, question marks, and pchars. If you look up the RFC, you'll see that the hash mark is not a valid pchar.
但是浏览器会尽量通过处理重复哈希来读取无效的URL,就像它们被转义一样,你可以通过检查 window.location.hash 的值来看到(在IE,Firefox和Chrome中
However, browsers will try their best to read non-valid URLs by treating repeat hashes as though they are escaped, as you can see by checking the value of window.location.hash (in IE, Firefox, and Chrome) for
www.example/hey#foo#bar这与 window.location.hash 相同
www.example/hey#foo%23bar更多推荐
URL中有多个哈希标志
发布评论