越简单越好!

如何抓取?PP=ss&DD=dd的参数

发表于 2006-12-28 14:13 | 1116次阅读 0次点赞   JavaScript
<script language="JavaScript">
<!-
var LocString=String(window.document.location.href);
function GetQueryString(str){
var rs=new RegExp("(^|)"+str+"=([^&]*)(&|$)","gi").exec(LocString),tmp;
if(tmp=rs)return tmp[2];
return "没有这个参数";
}
alert("参数一:"+GetQueryString("PP"));
alert("参数二:"+GetQueryString("DD"));
-->
</script> 


<script type="text/javascript">
var locString = location.search;
function getQueryString(key){
  var reg = new RegExp("(&)" + key + "=([^\&]*)(\&?)", "i").exec(locString);
  return RegExp.$2;
}
alert(getQueryString("test"));
// URL: fileName.html?test=HelloWorld
</script>


返回顶部 ^