aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/decodeuri
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/decodeuri')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/decodeuri/index.html121
1 files changed, 121 insertions, 0 deletions
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
+---
+<div>{{jsSidebar("Objects")}}</div>
+
+<div></div>
+
+<p><code><strong>decodeURI()</strong></code> 函数能解码由{{jsxref("encodeURI")}} 创建或其它流程得到的统一资源标识符(URI)。</p>
+
+<p>{{EmbedInteractiveExample("pages/js/globalprops-decodeuri.html")}}</p>
+
+<div class="hidden">
+<p>The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
+</div>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><code>decodeURI(<em>encodedURI</em>)</code></pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>encodedURI</code></dt>
+ <dd>一个完整的编码过的 URI</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>返回一个给定编码统一资源标识符(URI)的未编码版本的新字符串。</p>
+
+<h3 id="异常">异常</h3>
+
+<p>当<code><em>encodedURI</em></code> 包含无效字符序列时,引发{{jsxref("URIError")}}(“格式错误的URI序列”)异常。</p>
+
+<h2 id="描述">描述</h2>
+
+<p>将已编码 URI 中所有能识别的转义序列转换成原字符,但不能解码那些不会被 {{jsxref("encodeURI")}} 编码的内容(例如 "<code>#</code>")。</p>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="解码一个西里尔字母(Cyrillic)URL">解码一个西里尔字母(Cyrillic)URL</h3>
+
+<pre class="brush: js">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_шеллы"
+</pre>
+
+<h3 id="捕捉异常">捕捉异常</h3>
+
+<pre>try {
+ var a = decodeURI('%E0%A4%A');
+} catch(e) {
+ console.error(e);
+}
+
+// URIError: malformed URI sequence</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES3')}}</td>
+ <td>{{Spec2('ES3')}}</td>
+ <td>初始定义</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.1.3.1', 'decodeURI')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-decodeuri-encodeduri', 'decodeURI')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-decodeuri-encodeduri', 'decodeURI')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div class="hidden">
+<p>The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+</div>
+
+<p>{{Compat("javascript.builtins.decodeURI")}}</p>
+
+<h2 id="相关链接"><br>
+ <span style="">相关链接</span></h2>
+
+<div id="compat-mobile"></div>
+
+<ul>
+ <li>{{jsxref("decodeURIComponent")}}</li>
+ <li>{{jsxref("encodeURI")}}</li>
+ <li>{{jsxref("encodeURIComponent")}}</li>
+</ul>
+
+<p>
+ <audio style="display: none;"></audio>
+</p>
+
+<p>
+ <audio style="display: none;"></audio>
+</p>