escape,encodeURI,encodeURIComponent函数比较
escape,encodeURI,encodeURIComponent函数比较
|
js对文字进行编码涉及3个函数:escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decodeURIComponent 1、 传递参数时需要使用encodeURIComponent,这样组合的url才不会被#等特殊字符截断。 例如:<script language="javascript">document.write('<a 2、 进行url跳转时可以整体使用encodeURI 例如:Location.href=encodeURI("http://cang.baidu.com/do/s?word=百度&ct=21"); 3、 js使用数据时可以使用escape 例如:搜藏中history纪录。 4、 escape对0-255以外的unicode值进行编码时输出%u****格式,其它情况下escape,encodeURI,encodeURIComponent编码结果相同。 最多使用的应为encodeURIComponent,它是将中文、韩文等特殊字符转换成utf-8格式的url编码,所以如果给后台传递参数需要使用encodeURIComponent时需要后台解码对utf-8支持(form中的编码方式和当前页面编码方式相同) escape不编码字符有69个:*,+,-,.,/,@,_,0-9,a-z,A-Z encodeURI不编码字符有82个:!,#,$,&,',(,),*,+,,,-,.,/,:,;,=,?,@,_,~,0-9,a-z,A-Z encodeURIComponent不编码字符有71个:!, ',(,),*,-,.,_,~,0-9,a-z,A-Z escape 方法 escape(charString) 必选项 charstring 参数是要编码的任意 String 对象或文字。 说明 字符值大于 255 的以 %uxxxx 格式存储。 注意 escape 方法不能够用来对统一资源标示码 encodeURI 方法 encodeURI(URIString) 必选的 URIString 参数代表一个已编码的 URI。 说明 encodeURIComponent 方法 encodeURIComponent(encodedURIString) 必选的 encodedURIString 参数代表一个已编码的 URI 组件。 说明 |
escape,encodeURI,encodeURIComponent函数比较的更多相关文章
- JavaScript escape encodeURI encodeURIComponent() 函数
总结一下: 1.encodeURI(),和encodeURIComponent()是对字符进行编码. 2.decodeURI(),和decodeURIComponent()是对相应编码过的字符进行解码 ...
- url的三个js编码函数escape(),encodeURI(),encodeURIComponent()简介
url的三个js编码函数escape(),encodeURI(),encodeURIComponent()简介 2014年10月12日 16806次浏览 引子 浏览器URl地址,上网一定会用到,但是浏 ...
- url的三个js编码函数escape(),encodeURI(),encodeURIComponent()简介【转】
引子 浏览器URl地址,上网一定会用到,但是浏览器地址有中文或者浏览器url参数操作的时候,经常会用到encodeURIComponent()和decodeURIComponent()以及encode ...
- JavaScript中有三个可以对字符串编码的函数,分别是: escape(),encodeURI(),encodeURIComponent()
JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...
- JavaScript中有对字符串编码的三个函数:escape,encodeURI,encodeURIComponent
JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...
- escape,encodeURI,encodeURIComponent
JavaScript/js中,有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,d ...
- Flex中escape/encodeURI/encodeURIComponent的区别
Flex中提供了三种转码函数,各有各的区别, escape,encodeURI,encodeURIComponent 这三个函数不仅在flex中有道运用在javascript中同样的含义 ,今天我仔细 ...
- js中的三个编码函数:escape,encodeURI,encodeURIComponent
1. eacape(): 该方法不会对 ASCII 字母和数字进行编码,也不会对下面这些 ASCII 标点符号进行编码: * @ - _ + . / .其他所有的字符都会被转义序列替换.其它情况下es ...
- JavaScript中编码函数escape,encodeURI,encodeURIComponent
第一:escape():对字符串进行编码,escape()不编码的字符:@*/+ 第二:encodeURI() 函数可把字符串作为 URI 进行编码.不会进行转义的:;/?:@&=+$,# 第 ...
随机推荐
- cocos2d-x plist在拍照
if(!CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("scrollicon_bg.png" ...
- ionic入门之基本布局
目录: 简介 Hybrid vs. Others ionic CSS框架 基本布局 布局模式 定高条块:.bar .bar : 位置 .bar : 嵌入子元素 .bar : 嵌入input 内容:.c ...
- SQL常规查询详解
一.交叉连接(cross join) 交叉连接(cross join):有两种,显式的和隐式的,不带on子句,返回的是两表的乘积,也叫笛卡尔积. 例如:下面的语句1和语句2的结果是相同的. 语句1:隐 ...
- selenium之多线程启动grid分布式测试框架封装(四)
九.工具类,启动所有远程服务的浏览器 在utils包中创建java类:LaunchAllRemoteBrowsers package com.lingfeng.utils; import java.n ...
- AngularJS学习笔记(一)——一些基本知识
(一)Hello Angular index.html <!DOCTYPE html> <html ng-app> <head> <title>Test ...
- Windows Server 2008安装 百度Wifi \ 360Wifi \ 小米Wifi 失败的解决方法
服务器管理 -> 功能 -> 安装 [无线LAN]服务
- Python 3.3 try catch所有的错误Error,不包括Exception。关键在于 sys.exc_info()
import os; import sys; #---------------------------------------------- def main( ) : try : a = 1 / 0 ...
- [译]Java 设计模式之组合
(文章翻译自Java Design Pattern: Composite) 组合模式相对来说是比较简单的,但是它在很多设计中被用到,比如SWT.Eclipse工作空间等等.它创建了一个可以通过唯一的方 ...
- leetcode第23题--Swap Nodes in Pairs
Problem: Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1 ...
- Hudson安装配置、部署应用及分析
一.部署环境 机器:一台linux虚机,内存1G,操作系统CentOS release 5.6,硬盘100G. 实验应用:乐学方舟后台部署(非正式环境) 应用环境:apache-tomcat-7.0. ...