方法一: < type="text/java">
<!--
Request(strName){
 var strHref = "www.cnlei.org/index.htm?a=aaa&b=bbb&c=ccc";
 var intPos = strHref.indexOf("?");
 var strRight = strHref.substr(intPos + 1);
 var arrTmp = strRight.split("&");
 for(var i = 0; i < arrTmp.length; i++) {
 var arrTemp = arrTmp.split("=");
 if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
 }
 return "";
}
alert(Request("a"));
alert(Request("b"));
alert(Request("c"));
//-->
</>
方法二: < type="text/java">
<!--
String.prototype.getQuery = (name) {
  var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  var r = this.substr(this.indexOf("/?")+1).match(reg);
  if (r!=null) return unescape(r[2]); return null;
}
var strHref = "www.cnlei.org/index.htm?a=aaa&b=bbb&c=ccc";
alert(strHref.getQuery("a"));
alert(strHref.getQuery("b"));
alert(strHref.getQuery("c"));
//-->
</>
方法三: < type="text/java">
getUrlPara(paraName){
 var sUrl  =  location.href;
 var sReg  =  "(?://?|&){1}"+paraName+"=([^&]*)"
 var re=new RegExp(sReg,"gi");
 re.exec(sUrl);
 return RegExp.$1;
}
//应用实例:test_para.html?a=11&b=22&c=33
alert(getUrlPara("a"));
alert(getUrlPara("b"));
//location.href能够获取当前页面的路径
</>
 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/hanghwp/archive/2007/06/27/1668996.aspx