首页 > 代码库 > 前端页面获取地址栏传值

前端页面获取地址栏传值

function GetRequest() {
var url = location.search;
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}

//获取地址栏某个参数值

 

$("#selectiveProject" + i).attr("src", "/QualityAssurance/CheckInspection?&getoffcanvasid=ProjectName" + i + "&typeid=2&keytypeq=" + GetKeyValue("keytype") + "");  //父页面

//公共方法

function GetKeyValue(key) {
var Request = new Object();
Request = GetRequest();
var KeyValue;
if (Request[key] == null || Request[key] == "") { KeyValuehttp://www.mamicode.com/= ""; } else { KeyValue = http://www.mamicode.com/Request[key]; }
return KeyValue;
}

 

//子页面

var keytype = GetKeyValue("keytypeq");

前端页面获取地址栏传值