转义字符串:encodeURIComponent(str)
解析字符串:decodeURIComponent(str)
<html>
<body>
<script type="text/javascript">
var test1="http://www.w3school.com.cn/My first/"
document.write(encodeURIComponent(test1)+ "<br />")
document.write(decodeURIComponent(test1))
</script>
</body>
</html>