在线文档教程

escape

escape

废弃的 escape()方法生成新的由十六进制转义序列替换的字符串. 使用encodeURIencodeURIComponent代替.

语法

escape(str)

参数

str待编码的字符串.

返回值

一个新字符串,其中某些字符已经被转义。

描述

escape 函数是全局对象的属性. 特色字符如: @*_+-./ 被排除在外.

字符的16进制格式值,当该值小于等于0xFF时,用一个2位转移序列: %xx 表示. 大于的话则使用4位序列:%uxxxx 表示.

示例

escape('abc123' // "abc123" escape('äöü' // "%E4%F6%FC" escape('ć' // "%u0107" // special characters escape('@*_+-./' // "@*_+-./"

规范

SpecificationStatusComment
ECMAScript 1st Edition (ECMA-262)StandardInitial definition.
ECMAScript 5.1 (ECMA-262)The definition of 'escape' in that specification.StandardDefined in the (informative) Compatibility Annex B
ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'escape' in that specification.StandardDefined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers
ECMAScript Latest Draft (ECMA-262)The definition of 'escape' in that specification.Living StandardDefined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)

FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)