获取URL的参数值

<body>
<a href="javascript:location.href=location.href + '?a=1&b=2'">search</a>
<script language="JavaScript">
<!--
var a = location.search.substr(1);
if(a.length>0)
{
 var re = /([^&]*?)\=([^&]*)/g
 var s = a.match(re);
 for(var i= 0;i<s.length;i++)
 {
  alert(s[i]);
  alert(s[i].split("=")[1]);
 }
}
//-->
</script>
</body>
posted on 2008-06-27 16:49  念时  阅读(273)  评论(0编辑  收藏  举报

细节决定成败!态度决定一切!