var request = function (keyValue) {
var search = location.search.slice(1);
var arr = search.split("&");
for (var i = 0; i < arr.length; i++) {
var ar = arr[i].split("=");
if (ar[0] == keyValue) {
if (unescape(ar[1]) == 'undefined') {
return "";
} else {
return unescape(ar[1]);
}
}
}
return "";
}
调用示例:
var user = request('user');