<h2 >定义和用法</h2><p >decodeURIComponent() 函数可对 encodeURIComponent() 函数编码的 URI 进行解码。</p><h3 >语法</h3><pre >decodeURIComponent(URIstring)</pre><table class="dataintable" width="809"><tbody ><tr class="firstRow"><th >参数</th><th >描述</th></tr><tr ><td >URIstring</td><td >必需。一个字符串,含有编码 URI 组件或其他要解码的文本。</td></tr></tbody></table><h3 >返回值</h3><p >URIstring 的副本,其中的十六进制转义序列将被它们表示的字符替换。</p><h2 >实例</h2><p >在本例中,我们将使用 decodeURIComponent() 对编码后的 URI 进行解码:</p><pre >&lt;scripttype=&quot;text/javascript&quot;&gt; vartest1=&quot;http://www.w3school.com.cn/Myfirst/&quot; document.write(encodeURIComponent(test1)+&quot;&lt;br/&gt;&quot;) document.write(decodeURIComponent(test1)) &lt;/script&gt;</pre><p >输出:</p><pre >http%3A%2F%2Fwww.w3school.com.cn%2FMy%20first%2F http://www.w3school.com.cn/Myfirst/</pre>
T:0.012361s,M:157.12 KB
返回顶部 留言