Latest web development tutorials

JavaScript unescape() 函數

函數參考手冊 JavaScript全局函數

定義和用法

unescape() 函數可對通過escape() 編碼的字符串進行解碼。

提示:使用函數escape()對字符串進行編碼。

語法

unescape(string)

参数 描述
string 必需。要解码的字符串。


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要瀏覽器都支持unescape() 函數。


提示和註釋

注意: unescape()不能使用於對URI(通用資源標識符:UniformResourceIdentifier,簡稱"URI")精選解碼.解碼URI請使用decodeURI()方法。


實例

實例

在本例中,我們將使用escape() 來編碼字符串,然後使用unescape() 對其解碼:

<script>

var str="Need tips? Visit W3Schools!";
var str_esc=escape(str);
document.write(str_esc + "<br>")
document.write(unescape(str_esc))

</script>

以上實例輸出結果:

Need%20tips%3F%20Visit%20W3Cschool%21
Need tips? Visit W3Cschool!

嘗試一下»


函數參考手冊 JavaScript全局函數