decodeURIComponent() 解碼函数/二進制字符解碼&encodeURIComponent()

 ---獲取頁面傳值,若為漢字二進制字符可使用decodeURIComponent()解碼

       --var Emp_name = GetQuery('Emp_name'); 取值
     --var Wdate = GetQuery('Wdate');取值

語法
decodeURIComponent(URIstring):URIstring 必需。一个字符串,含有编码 URI 组件或其他要解码的文本。
decodeURIComponent() 函数可对 encodeURIComponent() 函数编码的 URI 进行解码。

<html>
<body>

<script type="text/javascript">

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

</script>

</body>
</html>

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

 

posted @ 2020-03-20 09:16  A大洋芋  阅读(348)  评论(0编辑  收藏  举报