标签:uri 菜鸟 现象 中控 ref .com component http doc
在使用encodeURIComponent此方法时,出现了如下奇怪的现象。
1.
http://www.w3school.com.cn/tiy/t.asp?f=jseg_encodeURIComponent
在w3school的网站上,得到如下结果。
document.write(encodeURIComponent("?")+"<br />"); //%26%23169%3B
document.write(encodeURIComponent("©")+"<br />"); //%26%23169%3B
document.write(decodeURIComponent("%26%23169%3B")+"<br />"); //?, 但是我自己去使用此方法解析时却是©
2.在菜鸟教程的网站上:http://www.runoob.com/try/try.php?filename=tryjsref_encodeuricomponent
document.write(encodeURIComponent("?")); %C2%A9
此时利用 %C2%A9去解码反倒是得到了正确的解析,即?。
3.在谷歌开发者工具中控制台键入
encodeURIComponent("?");
"%C2%A9"
最终:
个人认为w3school上的编码方法出错,因为对?和©得到了同样的结果。
标签:uri 菜鸟 现象 中控 ref .com component http doc
原文地址:http://www.cnblogs.com/yyzyxy/p/7747040.html