URL中的多个片段标识符正确吗?

编程入门 行业动态 更新时间:2024-10-22 23:30:53
本文介绍了URL中的多个片段标识符正确吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我偶然发现了一个在其URL中使用多个片段标识符的网站,例如 www.ejeby.se/#newprodukt#produkt#1075#1 (不,这不是我的网站,但我正在链接到它,这给我带来了问题).

I stumbled across a site that uses multiple fragment identifiers in their URLs, like www.ejeby.se/#newprodukt#produkt#1075#1 (no, it is not my site, but I am linking to it, which brings problems for me).

但这真的正确吗?它似乎确实会给Safari和Internet Explorer造成问题(传闻,我本人没有尝试过IE).

But is this really correct? It does seem to cause problems for Safari and possibly also Internet Explorer (hearsay, I have not tried IE myself).

片段标识符不是应该唯一地标识文档中的一个位置吗? 这是Safari中的错误,还是www.ejeby.se以错误的方式使用片段标识符?

Isn't the fragment identifier supposed to uniquely identify one location in the document? Is this a bug in Safari or is it www.ejeby.se that uses fragment idenifiers in a wrong way?

:似乎Safari的问题是它会转义URL中除第一个外的所有#号.其他浏览器不执行此操作.行为正确与否?

Seems that the problem for Safari is that it escapes all # but the first in the URL. The other browsers do not do this. Correct behaviour or not?

推荐答案

从规范的角度来看,片段可以包含以下字符(我已经扩展了作品):

From the specification point of view, a fragment can contain the following characters (I’ve already expanded the productions):

fragment = *( ALPHA / DIGIT / "-" / "." / "_" / "~" / "%" HEXDIG HEXDIG / "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" / ":" / "@" / "/" / "?" )

因此,不可以,该片段不能包含普通的#;它必须用%23编码.

So, no, the fragment must not contain a plain #; it must be encoded with %23.

但是某些浏览器可能会以不同的方式显示它,就像将代表有效UTF-8字符的百分比编码八位字节序列替换为它们所代表的字符一样.

But it is possible that some browsers display it differently just as sequences of percent-encoded octets, that represent valid UTF-8 characters are replaced by the characters they represent.

更多推荐

URL中的多个片段标识符正确吗?

本文发布于:2023-10-12 23:29:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1486194.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   标识符   片段   正确   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!