首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

decodeURIComponent

decodeURIComponent()方法用于解码由encodeURIComponent方法或者其它类似方法编码的部分统一资源标识符(URI)。

语法

代码语言:javascript
复制
decodeURIComponent(encodedURI)

参数

encodedURI编码后的部分 URI

返回值

表示给定编码的统一资源标识符(URI)组件的解码版本。

异常

URIError使用错误时会抛出(“格式不正确的URI序列”)异常。

描述

将已编码 URI 中所有能识别的转义序列转换成原字符。

示例

解码一个西里尔字母的URL

代码语言:javascript
复制
decodeURIComponent('JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B');
// "JavaScript_шеллы"

捕获异常

代码语言:javascript
复制
try { 
  var a = decodeURIComponent('%E0%A4%A'); 
} catch(e) { 
  console.error(e); 
}

// URIError: malformed URI sequence

规范

Specification

Status

Comment

ECMAScript 3rd Edition (ECMA-262)

Standard

Initial definition.

ECMAScript 5.1 (ECMA-262)The definition of 'decodeURIComponent' in that specification.

Standard

?

ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'decodeURIComponent' in that specification.

Standard

?

ECMAScript Latest Draft (ECMA-262)The definition of 'decodeURIComponent' in that specification.

Draft

?

浏览器兼容性

Feature

Chrome

Edge

Firefox (Gecko)

Internet Explorer

Opera

Safari

Basic support

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

Feature

Android

Chrome for Android

Edge

Firefox Mobile (Gecko)

IE Mobile

Opera Mobile

Safari Mobile

Basic support

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com