码迷,mamicode.com
首页 > Web开发 > 详细

encodeURIComponent方法

时间:2017-10-28 16:33:00      阅读:187      评论:0      收藏:0      [点我收藏+]

标签: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("&#169;")+"<br />");                                              //%26%23169%3B
document.write(decodeURIComponent("%26%23169%3B")+"<br />");                             //?,                                                  但是我自己去使用此方法解析时却是&#169;

 

2.在菜鸟教程的网站上:http://www.runoob.com/try/try.php?filename=tryjsref_encodeuricomponent

document.write(encodeURIComponent("?"));                                                                         %C2%A9

此时利用   %C2%A9去解码反倒是得到了正确的解析,即?。

3.在谷歌开发者工具中控制台键入

encodeURIComponent("?");
"%C2%A9"

最终:

个人认为w3school上的编码方法出错,因为对?和&#169;得到了同样的结果。

 

encodeURIComponent方法

标签:uri   菜鸟   现象   中控   ref   .com   component   http   doc   

原文地址:http://www.cnblogs.com/yyzyxy/p/7747040.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!