JavaScript decodeURIComponent() 函数

来源:互联网 发布:数据结构排序算法口诀 编辑:程序博客网 时间:2024/05/21 12:34
 

JavaScript 全局对象参考手册

定义和用法

decodeURIComponent() 函数可对 encodeURIComponent() 函数编码的 URI 进行解码。

语法

decodeURIComponent(URIstring)
参数描述URIstring必需。一个字符串,含有编码 URI 组件或其他要解码的文本。

返回值

URIstring 的副本,其中的十六进制转义序列将被它们表示的字符替换。

实例

在本例中,我们将使用 decodeURIComponent() 对编码后的 URI 进行解码:

<script type="text/javascript">var test1="http://www.w3school.com.cn/My first/"document.write(encodeURIComponent(test1)+ "<br />")document.write(decodeURIComponent(test1))</script>

输出:

http%3A%2F%2Fwww.w3school.com.cn%2FMy%20first%2Fhttp://www.w3school.com.cn/My first/

TIY

decodeURIComponent()
如何使用 decodeURIComponent() 对编码后的 URI 进行解码。

JavaScript 全局对象参考手册

原创粉丝点击