From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../reference/global_objects/decodeuri/index.html | 121 +++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/decodeuri/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/decodeuri') diff --git a/files/zh-cn/web/javascript/reference/global_objects/decodeuri/index.html b/files/zh-cn/web/javascript/reference/global_objects/decodeuri/index.html new file mode 100644 index 0000000000..dfaaf7e104 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/decodeuri/index.html @@ -0,0 +1,121 @@ +--- +title: decodeURI() +slug: Web/JavaScript/Reference/Global_Objects/decodeURI +tags: + - JavaScript + - URI + - decodeURI() + - 统一资源标识符 +translation_of: Web/JavaScript/Reference/Global_Objects/decodeURI +--- +
{{jsSidebar("Objects")}}
+ +
+ +

decodeURI() 函数能解码由{{jsxref("encodeURI")}} 创建或其它流程得到的统一资源标识符(URI)。

+ +

{{EmbedInteractiveExample("pages/js/globalprops-decodeuri.html")}}

+ + + +

语法

+ +
decodeURI(encodedURI)
+ +

参数

+ +
+
encodedURI
+
一个完整的编码过的 URI
+
+ +

返回值

+ +

返回一个给定编码统一资源标识符(URI)的未编码版本的新字符串。

+ +

异常

+ +

encodedURI 包含无效字符序列时,引发{{jsxref("URIError")}}(“格式错误的URI序列”)异常。

+ +

描述

+ +

将已编码 URI 中所有能识别的转义序列转换成原字符,但不能解码那些不会被 {{jsxref("encodeURI")}} 编码的内容(例如 "#")。

+ +

示例

+ +

解码一个西里尔字母(Cyrillic)URL

+ +
decodeURI("https://developer.mozilla.org/ru/docs/JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B");
+// "https://developer.mozilla.org/ru/docs/JavaScript_шеллы"
+
+ +

捕捉异常

+ +
try {
+  var a = decodeURI('%E0%A4%A');
+} catch(e) {
+  console.error(e);
+}
+
+// URIError: malformed URI sequence
+ +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
规范状态备注
{{SpecName('ES3')}}{{Spec2('ES3')}}初始定义
{{SpecName('ES5.1', '#sec-15.1.3.1', 'decodeURI')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-decodeuri-encodeduri', 'decodeURI')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-decodeuri-encodeduri', 'decodeURI')}}{{Spec2('ESDraft')}}
+ +

浏览器兼容性

+ + + +

{{Compat("javascript.builtins.decodeURI")}}

+ +


+ 相关链接

+ +
+ + + +

+ +

+ +

+ +

-- cgit v1.2.3-54-g00ecf