encodeURI() 函数可把字符串作为 URI 进行编码。
--------------------------------------------------------------------------------------------
输入:
<script type="text/javascript">
document.write(encodeURI("http://www.w3school.com.cn")
+ "<br />")
document.write(encodeURI("http://www.w3school.com.cn/My first/")
)
document.write(encodeURI(",/?:@&=+$#")
)
</script>
-------------------------------------------------------------------------------------------------
输出:
http://www.w3school.com.cn
http://www.w3school.com.cn/My%20first/
,/?:@&=+$#