JavaScript decodeURI() 函數(shù)

定義和用法
decodeURI() 函數(shù)可對 encodeURI() 函數(shù)編碼過的 URI 進行解碼。
提示: 使用 encodeURI() 函數(shù)可以對 URI 進行編碼。
語法
decodeURI(uri)
參數(shù) | 描述 |
---|---|
uri | 必需。一個字符串,含有要解碼的 URI 或其他要解碼的文本。 |
瀏覽器支持
The decodeURI() function 所有主要瀏覽器都支持
實例
Example
使用 decodeURI() 對一個編碼后的 URI 進行解碼:
<script>
var uri="my test.asp?name=st?le&car=saab";
document.write(encodeURI(uri)+ "<br>");
document.write(decodeURI(uri));
</script>
var uri="my test.asp?name=st?le&car=saab";
document.write(encodeURI(uri)+ "<br>");
document.write(decodeURI(uri));
</script>
以上實例輸出結果:
my%20test.php?name=st%C3%A5le&car=saab
my test.asp?name=st?le&car=saab
my test.asp?name=st?le&car=saab
嘗試一下 ?

更多建議: