javascript 根据参数ID获取链接地址的参数值
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.jzread.com/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>javascript 根据参数ID获取链接地址的参数值</title>
<script language="javascript">
//根据参数ID获取链接地址的参数值
function getthe_hrefvar(strVar)
{
var the_urlvar="0";
if(strVar)
{
if(document.location.search.substr(1))
{
var aParams = document.location.search.substr(1).split('&');
for (i=0; i<aParams.length; i++)
{
var aParam = aParams[i].split('=');
if(aParam[0]==strVar)
{
the_urlvar = aParam[1];
break;
}
}
}
}
return the_urlvar;
}
//http://jzread.com/index.html?&id=22
var url = getthe_hrefvar('id');
alert(url);//22
</script>
</head>
<body>
</body>
</html>