post頁面:
window.location.href=encodeURI('workList.html?title=aaa&name=吳思源');
Recive頁面:
var url = decodeURI(location.search);
var Request = new Object();
if(url.indexOf("?") != -1) {
var str = url.substr(1)
strs = str.split("&");
for(var i = 0; i < strs.length; i++){
Request[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
alert(Request["title"])
alert(Request["name"])
注意:
??傳值中文時(shí),會(huì)出現(xiàn)亂碼現(xiàn)在,我們可以在post頁面用encodeURI()編碼,在red界面用decodeURI()解碼。