请求为 abc.do?id=1&name=slf,
jQuery.queryString = function(query) {
var search = window.location.search + '';
if (search.charAt(0) != '?') {
return undefined;
}
else {
search = search.replace('?', '').split('&');
for (var i = 0; i < search.length; i++) {
if (search[i].split('=')[0] == query) {
return decodeURI(search[i].split('=')[1]);
}
}
return undefined;
}
};
JS中可以通过
var id = jQuery.queryString("id");
var name = jQuery.queryString("name");
进行截取