Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么维基百科在他们的URL片段中使用修改过的百分比编码?_Url_Fragment Identifier_Percent Encoding_Url Design - Fatal编程技术网

为什么维基百科在他们的URL片段中使用修改过的百分比编码?

为什么维基百科在他们的URL片段中使用修改过的百分比编码?,url,fragment-identifier,percent-encoding,url-design,Url,Fragment Identifier,Percent Encoding,Url Design,我注意到Wikipedia对URL的路径部分使用百分比编码,但将%字符转换为作为#片段 例如,在上,的URL为 http://ru.wikipedia.org/wiki/%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D1%8F#.D0.98.D1.81.D1.82.D0.BE.D1.80.D0.B8.D1.8F 而不是 http://ru.wikipedia.org/wiki/%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D1%8F#%D0%98%D1%81%D1

我注意到Wikipedia对URL的路径部分使用百分比编码,但将
%
字符转换为
作为#片段

例如,在上,的URL为

http://ru.wikipedia.org/wiki/%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D1%8F#.D0.98.D1.81.D1.82.D0.BE.D1.80.D0.B8.D1.8F

而不是

http://ru.wikipedia.org/wiki/%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D1%8F#%D0%98%D1%81%D1%82%D0%BE%D1%80%D0%B8%D1%8F


两者都不是有效的HTML一个可能的答案是跨浏览器问题。浏览器处理unicode的方式不一致,尤其是URL片段

例如,使用链接

但有一个片段:

href=
javascript:document.getElementById('foo')。href

path=
javascript:location.pathname
在以下链接之后

hash=
javascript:location.hash
在下面的链接之后

因此,当您请求散列时,Firefox会将片段的百分比编码解码为unicode,导致其与id/name属性的值不匹配。注意,这只是JavaScript中的一个问题;下面的链接很好用

Browser      | Hover   | Location bar | href*   | path*
----------------------------------------------------------
Chrome 19    | Unicode | Unicode      | Percent | Percent
Firefox 13   | Unicode | Unicode      | Percent | Percent
IE 9         | Percent | Percent      | Percent | Percent
Browser      | Hover   | Location bar | href*   | hash*
----------------------------------------------------------
Chrome 19    | Percent | Percent      | Percent | Percent
Firefox 13   | Unicode | Unicode      | Percent | Unicode
IE 9         | Percent | Percent      | Percent | Percent