页面A:
document.getElementById("a").href = "A.aspx?keyword=" + encodeURI(encodeURI("我的传参"));
页面B:
alert(decodeURI(getQueryString("keyword")));
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
已验证通过,希望对大家有帮助。
js里面的encodeURI()对应C#
System.Web.HttpUtility.UrlEncode("", System.Text.Encoding.GetEncoding("GB2312"))
decodeURI()对应C#中
System.Web.HttpUtility.UrlDecode("%B1%E0%C2%EB", System.Text.Encoding.GetEncoding("GB2312")));