开发者

Safari multiple hashtags

I recently tested my site on Safari and for some odd reason it only reads the first hashtag in the url

http://www.mangamanga.com/mangaReader.php#mangaNo=3%23chapterNo=8%23pageNo=1

while in all the other browsers it looks like this

http://www.mangamanga.com/mangaRe开发者_开发问答ader.php#mangaNo=3#chapterNo=8#pageNo=1

could someone please explain why this is happening.


The hash (#) is a reserved character in URLs. Any characters following the hash are the fragment portion of a URL. So Safari is escaping the extra illegal hashes to %23.

http://labs.apache.org/webarch/uri/rfc/rfc3986.html


A plain # is actually not allowed in the fragment component:

fragment    = *( pchar / "/" / "?" )

Where pchar is equivalent to this expansion:

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

No plain # there. So Safari’s behavior would be the expected behavior.

But maybe the other browsers are just displaying the %23 as # for readability.


%23 is how # symbols are escaped. Apparently Safari feels like doing this, where other browsers don't. It seems to load the same page in any case.

Here's a list of escape codes: http://www.december.com/html/spec/esccodes.html


What most people have been saying is true; Safari does see it as an illegal character (the second hash) but other modern browsers (IE/Chrome) are fine with them.

Gumbo stated that the other browsers are just displaying the second hash as # but it's really %23. This is incorrect as far as I can tell, because using a document.location.hash.split('#') will give you the following array:

[0] - http://www.mangamanga.com/mangaReader.php#mangaNo=3
[1] - chapterNo=8
[2] - pageNo=1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜