function getQueryObject(url) { url = url == null ? window.location.href : url; ??var search = url.substring(url.lastIndexOf("?") + 1); ??var obj = {}; ???????var reg = /([^?&=]+)=([^?&=]*)/g; ??search.replace(reg, function (rs, $1, $2) { ? var name = decodeURIComponent($1); ?? var val = decodeURIComponent($2); ? val = String(val); ? obj[name] = val;
?? return rs; ?});
return obj;
}//该方法的目的是对 URI 进行完整的编码,因此对以下在 URI 中具有特殊含义的 ASCII 标点符号,encodeURI() 函数是不会进行转义的:;/?:@&=+$,#//decodeURIComponent($1);//URI解码 ?encodeURIComponent加密(所有的)
正则匹配url参数
原文地址:http://www.cnblogs.com/theArrow/p/7895198.html