JS加解密URL参数encodeURIComponent() decodeURIComponent()

参考1:http://www.w3school.com.cn/js/jsref_encodeURIComponent.asp

参考2:http://www.w3school.com.cn/js/jsref_decodeURIComponent.asp

 

实例:

<script type="text/javascript">

var test1="http://www.w3school.com.cn/My first/"

document.write(encodeURIComponent(test1)+ "<br />")
document.write(decodeURIComponent(test1))

</script>

输出:

http%3A%2F%2Fwww.w3school.com.cn%2FMy%20first%2F
http://www.w3school.com.cn/My first/

  

posted on 2013-06-27 15:59  王培  阅读(1611)  评论(0编辑  收藏  举报

导航