参考(a.html 访问到b.html --> b.html?uc=test):
function getunc(){
var nc = document.location.search;
alert(nc);
unc = nc.replace("?uc=","");
alert(unc);
}
function getunc(){
var nc = document.location.search;
alert(nc);
unc = nc.replace("?uc=","");
alert(unc);
}
a.html
<html>
<head>
<title>
</title>
</head>
<body>
<a href="B.html?Para=XX&id=rrr">B</a>
</body>
</html>
接受参数的b.html
<html>
<head>
<title>B</title>
<script type="text/javascript">
function load(){
var request = {
QueryString : function(val) {
var uri = window.location.search;
var re = new RegExp("" +val+ "=([^&?]*)", "ig");
return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null);
}
}
var para = request.QueryString("Para");
var id = request.QueryString("id");
alert(para);
alert(id);
}
</script>
</head>
<body onload="load()">
<input type="button" onclick="load()" value="Get" text="Get"/>
</body>
</html>
//'-----得到GET地址栏的参数值
function Request(strName)
{
var strHref = window.location.href;
//'-----取得?所在的位置
var intPos = strHref.indexOf("?");
//'-----取得?后面的一串字符
var strRight = strHref.substr(intPos + 1); //'-----以&为分隔符将得到的字符串赋给数组arrTemp
var arrTmp = strRight.split("&");
for(var i = 0; i < arrTmp.length; i++)
{
var arrTemp = arrTmp[i].split("=");
//'------如果传入的字符strName等于存在的参数,就返回对应的字符
if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
}
return "";
}function window.onload()
{
//这里调用Request重组你需要的参数,然后传递给b.html
}