http://localhost/Test.sapx?Code=123&name=1234
或
http://localhost/Test.html?Code=123&name=1234
页面javascript代码
<script>
$(window).load(function() {
var parameterURL = location.search.substring(1, location.search.length);
var paramArr = parameterURL.split("&");
var temp;
var postArgs = new Object();
for (i = 0; i < paramArr.length; i++) {
temp = paramArr[i].split("=");
if (temp.length == 1)
postArgs[temp[0]] = "";
else if (temp.length > 1) {
for (j = 0; j < temp.length; j++) {
postArgs[temp[0]] = temp[1];
}
}
}
var obj = jQuery.parseJSON(JSON.stringify(postArgs));//把参数转json对象
console.log(obj.Code);//根据参数名取值
});
</script>