JS中escape()、encodeURI()、encodeURIComponent()区别详解
<script type="text/javascript">
document.write(escape("http://www.w3school.com.cn/") + "<br />")
document.write(escape("?!=()#%&"))
</script>
输出:
http%3A//www.w3school.com.cn%3F%21%3D%28%29%23%25%26
<script type="text/javascript">
document.write(encodeURI("http://www.w3school.com.cn/")+ "<br />")
document.write(encodeURI("http://www.w3school.com.cn/My first/"))
document.write(encodeURI(",/?:@&=+$#"))
<script/>
http://www.w3school.com.cn/
http://www.w3school.com.cn/My%20first/
<script type="text/javascript">
document.write(encodeURIComponent("http://www.w3school.com.cn/"))
document.write("<br />")
document.write(encodeURIComponent("http://www.w3school.com.cn/p 1/"))
document.write("<br />")
document.write(encodeURIComponent(",/?:@&=+$#"))
</script>
http%3A%2F%2Fwww.w3school.com.cn http%3A%2F%2Fwww.w3school.com.cn%2Fp%201%2F%2C%2F%3F%3A%40%26%3D%2B%24%23
<script language="javascript">document.write('
<a href="http://passport.baidu.com/?logout&aid=7&u='+encodeURIComponent("http://cang.baidu.com/bruce42")+'">退出</a>');</script>
对URL中的参数进行编码,因为参数也是一个URL,如果不编码会影响整个URL的跳转。
JS中escape()、encodeURI()、encodeURIComponent()区别详解的更多相关文章
- [转]ESCAPE()、ENCODEURI()、ENCODEURICOMPONENT()区别详解
escape().encodeURI().encodeURIComponent()区别详解 JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encode ...
- Url解码和编码 escape()、encodeURI()、encodeURIComponent()区别详解
Server.UrlDecode;解码 Server.UrlEncode;编码 url编码是一种浏览器用来打包表单输入的格式.浏览器从表单中获取所有的name和其中的值 ,将它们以name/value ...
- 【转】escape()、encodeURI()、encodeURIComponent()区别详解
escape().encodeURI().encodeURIComponent()区别详解 原文链接:http://www.cnblogs.com/tylerdonet/p/3483836.html ...
- JS中的函数节流throttle详解和优化
JS中的函数节流throttle详解和优化在前端开发中,有时会为页面绑定resize事件,或者为一个页面元素绑定拖拽事件(mousemove),这种事件有一个特点,在一个正常的操作中,有可能在一个短的 ...
- Node.js中环境变量process.env详解
Node.js中环境变量process.env详解process | Node.js API 文档http://nodejs.cn/api/process.html官方解释:process 对象是一个 ...
- JS 字符串编码函数(解决URL特殊字符传递问题):escape()、encodeURI()、encodeURIComponent()区别详解
javaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...
- JS转义 escape()、encodeURI()、encodeURIComponent()区别详解
JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...
- escape()、encodeURI()、encodeURIComponent()区别详解 (转)
JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:,decodeURI,decodeURIComp ...
- escape()、encodeURI()、encodeURIComponent()区别详解--zt
JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...
随机推荐
- [系列] Go - json.Unmarshal 遇到的小坑
1.问题现象描述 使用 json.Unmarshal(),反序列化时,出现了科学计数法,参考代码如下: jsonStr := `{"number":1234567}` result ...
- SSTI(模板注入)
SSTI 一. 什么是SSTI 模板引擎(这里特指用于Web开发的模板引擎)是为了使用户界面与业务数据(内容)分离而产生的,它可以生成特定格式的文档,用于网站的模板引擎就会生成一个标准的HTML文档. ...
- .NET Core CLI 的性能诊断工具介绍
前言 开发人员的.NET Core项目上线后,经常会出现各种问题,内存泄漏,CPU 100%,处理时间长等, 这个时候就需要快速并准确的发现问题,并解决问题, 除了项目本身的日志记录外,NET Cor ...
- c++运行程序 改变字和背景的颜色与窗口大小和位置 (c++)(windows)
关于改变字体的颜色和背景颜色: 在#include <windows.h> 库里 0=黑色 1=蓝色 2=绿色 3=湖蓝色 4=红色 5=紫色 6=黄色 7=白色 8=灰色 9=淡蓝色 A ...
- J.U.C体系进阶(一):juc-executors 执行器框架
Java - J.U.C体系进阶 作者:Kerwin 邮箱:806857264@qq.com 说到做到,就是我的忍道! 主要内容: juc-executors 执行器框架 juc-locks 锁框架 ...
- Illegal instant due to time zone offset transition (Asia/Shanghai)_夏令时问题
项目报错信息: Connot parse "1991-04-14",illegal instant due to time zone offset transition(Asia/ ...
- 怎样从gitHub上面拉项目
1.注册 https://gitee.com/oschina 2.拿到代码在gitHub上的地址 3.打开eclipse-->import https://git.oschina.net/cai ...
- 用Eclipse进行单元测试JUnit4
(1)在项目中引入Jar包 (2)编写需要测试的类 public class Calculator { private static int result=0; // 静态变量,用于存储运行结 ...
- CentOS7上安装Hadoop
设置sshssh-keygen -t rsa -P ''cat id_rsa.pub >> authorized_keys 查看slaves节点的id_rsa.pub文件,将文件内容复制到 ...
- python numpy库np.percentile用法说明
在python中计算一个多维数组的任意百分比分位数,此处的百分位是从小到大排列,只需用np.percentile即可…… a = range(1,101) #求取a数列第90%分位的数值 np.per ...