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"])
注意:
传值中文时,会出现乱码现在,我们可以在post页面用encodeURI()编码,在red界面用decodeURI()解码。