decodeURIComponent()
方法用于解码由 encodeURIComponent
方法或者其它类似方法编码的部分统一资源标识符(URI)。
decodeURIComponent(encodedURI)
encodedURI
A new string representing the decoded version of the given encoded Uniform Resource Identifier (URI) component.
Throws an URIError
("malformed URI sequence") exception when used wrongly.
将已编码 URI 中所有能识别的转义序列转换成原字符。
decodeURIComponent("JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B");
// "JavaScript_шеллы"
try {
var a = decodeURIComponent('%E0%A4%A');
} catch(e) {
console.error(e);
}
// URIError: malformed URI sequence
规范 | 状态 | 备注 |
---|---|---|
ECMAScript 3rd Edition (ECMA-262) | Standard | 初始定义 |
ECMAScript 5.1 (ECMA-262) decodeURIComponent |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) decodeURIComponent |
Standard | |
ECMAScript Latest Draft (ECMA-262) decodeURIComponent |
Draft |
特性 | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
基础功能 | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
特性 | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
基础功能 | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |