js前端實現給url數據加密的方法
1.傳參頁面
<script type=”text/javascript”>// <![CDATA[function send(){
var url = "test01.html";
var userName = $("#userName").html();
window.open(encodeURI(url + "?userName=" + userName)); }
// ]]>
</script>
2.接收參數頁面
<script>
var urlinfo = window.location.href;//獲取url
var userName = urlinfo.split(“?”)[1].split(“=”)[1];
$(“#userName”).html(decodeURI(userName));
</script>