function urlparamater(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
function getUrlParams(name) { // 不传name返回所有值,否则返回对应值
var url = window.location.search;//search不行可能是hash
if (url.indexOf('?') == 1) {
return false;
}
url = url.substr(1);
url = url.split('&');
var name = name || '';
var nameres;
// 获取全部参数及其值
for (var i = 0; i < url.length; i++) {
var info = url[i].split('=');
var obj = {};
obj[info[0]] = decodeURI(info[1]);
url[i] = obj;
}
// 如果传入一个参数名称,就匹配其值
if (name) {
for (var i = 0; i < url.length; i++) {
for (const key in url[i]) {
if (key == name) {
nameres = url[i][key];
}
}
}
} else {
nameres = url;
}
// 返回结果,全部参数
return nameres;
}
window.onload = function () {
var CompanyName = this.getUrlParams("new_name");
var IdOrCode = this.getUrlParams("new_idorcode");
console.log(CompanyName, IdOrCode);
// acc(CompanyName, IdOrCode);
}