废话不多说,直接看代码!
var url = 'http://www.runoob.com/jquery/misc-trim.html?channelid=12333&name=xiaoming&age=23';
function URL(){
var sHref = window.location.href;
var args = sHref.split('?');
if (args[0] == sHref) {
return ''
};
var arr = args[1].split('&');
var obj = {};
for (var i = 0; i < arr.length; i++) {
var arg = arr[i].split('=');
obj[arg[0]] = arg[1];
}
return obj;
}
URL();
console.log('URL',URL());