JavaScript unescape() 函数 字符串解码
javascript中 unescape() 函数可对通过 escape() 编码的字符串进行解码,所有浏览器都兼容该方法。
注意:unescape() 函数已经从 Web 标准中删除,所以尽量不使用该函数,可以使用 decodeURI 或 decodeURIComponent 代替。
语法
unescape(string)
参数
- string : 必需。要解码的字符串。
实例
<html>
<head>
<meta charset="utf-8">
<title>IT懒猫 www.catroom.com.cn</title>
</head>
<body>
<script>
var str="hello boys and girls !";
var str_esc=escape(str);
document.write(str_esc + "<br>")
document.write(unescape(str_esc))
</script>
</body>
</html>
效果: