/**
* 获取地址栏参数
* @method queryURLParameter
* @param {url:不传默认是当前locationhref ,isEncoded:是否是加密,不加密false,加密需要解密:true}
* @return {参数对象}
* eg:https://i.cnblogs.com/EditPosts.aspx?opt=1&item=youth
* queryURLParameter(‘https://i.cnblogs.com/EditPosts.aspx?opt=1&item=youth‘,false)=>{opt:1,item:youth}
*/
function queryURLParameter(url, isEncode) {
url = url || window.location.href;
var obj = {}, reg = /([^?&=]+)=([^?&=]+)/g;
url.replace(reg, function () {
var arg = arguments;
obj[arg[1]] = isEncode ? decodeURIComponent(arg[2]) : arg[2];
});
return obj;
}
时间: 2024-10-29 10:45:39