escape、encodeURI、encodeURIComponent等方法的区别比较

2019-06-03 11:56:23于丽

版本 1

请参见
decodeURI 方法 | decodeURIComponent 方法 | escape 方法 | String 对象

适用于:Global 对象

decodeURI 方法
返回一个已编码的统一资源标识符 (URI) 的非编码形式。

function decodeURI(URIstring : String) : String
参数
URIstring
必选。表示编码 URI 的字符串。
备注
使用 decodeURI 方法代替已经过时的 unescape 方法。

decodeURI 方法返回一个字符串值。

如果 URIString 无效,将发生 URIError。

要求
版本 5.5

请参见
decodeURIComponent 方法 | encodeURI 方法

适用于:Global 对象

decodeURIComponent 方法
返回统一资源标识符 (URI) 的一个已编码组件的非编码形式。

function decodeURIComponent(encodedURIString : String) : String
必选的 encodedURIString 参数是一个表示已编码的 URI 组件的值。

备注
URIComponent 是一个完整的 URI 的一部分。

如果 encodedURIString 无效,则将产生 URIError。

要求
版本 5.5

请参见
decodeURI 方法 | encodeURI 方法

适用于:Global 对象