js获取get参数值代码

来源:岁月联盟 编辑:zhuzhu 时间:2009-10-20
<script language="JavaScript">
function Request(argname)
{
var url = document.location.href;
var arrStr = url.substring(url.indexOf("?")+1).split("&");
//return arrStr;
for(var i =0;i<arrStr.length;i++)
{
var loc = arrStr[i].indexOf(argname+"=");

if(loc!=-1)
{
return arrStr[i].replace(argname+"=","").replace("?","");
break;
}

}
return "";
}
//使用Request("argname")即可得到参数值;
</script>

本文出处:http://blog.csdn.net/logomaster/archive/2009/06/01/4233017.aspx