`encodeURI` 和 `encodeURIComponent`的区别
2015-12-08 12:29
232 查看
encodeURI
和 encodeURIComponent
的区别
encodeURI
加密一些URL中不允许的字符, 如空格等
var url = 'http://xx xxx/'; encodeURI(url); // 输出: "http://xx%20xxx/"
encodeURIComponent
加密query string中的一些特殊字符
var url = 'http://xx xxx/'; encodeURIComponent(url); // 输出: "http%3A%2F%2Fxx%20xxx%2F"
总结
当使用 http://www.judith.com?url=http://www.baidu.com 这种 query string 中带有 http:// 特殊字符时, 可以使用encodeURIComponent来进行加密
相关文章推荐
- java-用HttpURLConnection发送Http请求.
- VBScript 剪贴板抓取URL并在浏览器中打开
- 用vbs 实现从剪贴板中抓取一个 URL 然后在浏览器中打开该 Web 站点
- asp获取URL参数的几种方法分析总结[原创]_应用技巧_脚本之家
- zend framework框架中url大小写问题解决方法
- url decode problem 解决方法
- php url地址栏传中文乱码解决方法集合
- 探讨:parse url解析URL,返回其组成部分
- C#实现自动识别URL网址的方法
- C#自定义针对URL地址的处理类实例
- JavaScritp添加url参数并将参数加入到url中及更改url参数的方法
- ASP让url的中文显示为编码
- JS使用ajax方法获取指定url的head信息中指定字段值的方法
- 关于URL中的特殊符号使用介绍
- JS来动态的修改url实现对url的增删查改
- js url传值中文乱码之解决之道
- JavaScript操作URL的相关内容集锦
- jquery获取url参数及url加参数的方法
- 通过url查找a元素并点击
- 简单实例处理url特殊符号&处理(2种方法)