JS加载获取父窗体传递的参数

时间:2023-03-08 16:27:05
JS加载获取父窗体传递的参数
JS加载获取父窗体传递的参数
$(document).ready(function () {
var query = location.search.substring(1);
var values = query.split("&");
for (var i = 0; i < values.length; i++) {
var pos = values[i].indexOf('=');
if (pos == -1) continue;
var paramname = values[i].substring(0, pos);
var value = values[i].substring(pos + 1);
alert(paramname + "," + value);
}
}) JS获取父窗体传递的参数
var name, value, i;
var str = location.href; //获得浏览器地址栏URL串
var num = str.indexOf("?")
str = str.substr(num + 1); //截取“?”后面的参数串
var arrtmp = str.split("&"); //将各参数分离形成参数数组
for (i = 0; i < arrtmp.length; i++) {
num = arrtmp[i].indexOf("=");
if (num > 0) {
name = arrtmp[i].substring(0, num); //取得参数名称
value = arrtmp[i].substr(num + 1); //取得参数值
alert(name+ "," + value);
switch (name) {
case "CorpID":
var CorpID = value;
break;
case "ID":
var ID = value;
break;
case "ztype":
var ztype = value;
break;
case "Year":
var Year = value;
break;
}
}
} 后台获取父窗体传递的参数
var x = Request["PType"];
var y = Request["ProjectID"];