// 获取指定地址栏数据
//name:参数名 function GetQueryString(name, url) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); if (url == null || url == "") { url = window.location.search; //url没有传获取当前地址 } else { var i = url.indexOf("?"); url = url.substr(i); } var r = url.substr(1).match(reg); if (r != null) { return unescape(r[2]); } return null; }
// 获取所有地址栏数据 function GetAllUrlParam(data) { // 抓取地址栏数据 var params = (window.location.search.split('?')[1] || '').split('&'); for (var param in params) { if (params.hasOwnProperty(param)) { paramParts = params[param].split('='); var key = paramParts[0]; var value = decodeURIComponent(paramParts[1] || ""); AddParam(key, value, data); } } return data; }