代码如下:大家试试看吧!
<script> <BR><!-- <BR>function Request(strName) <BR>{ <BR>var strHref = "www.abc.com/index.htm?a=1&b=1&c=测试测试"; <BR>var intPos = strHref.indexOf("?"); <BR>var strRight = strHref.substr(intPos + 1); <br><br>var arrTmp = strRight.split("&"); <BR>for(var i = 0; i < arrTmp.length; i++) <BR>{ <BR>var arrTemp = arrTmp[i].split("="); <br><br>if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1]; <BR>} <BR>return ""; <BR>} <br><br>alert(Request("a")); <BR>alert(Request("b")); <BR>alert(Request("c")); <BR>//--> <BR></script>
<script> <BR>String.prototype.getQuery = function(name) <BR>{ <BR> var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); <BR> var r = this.substr(this.indexOf("\?")+1).match(reg); <BR> if (r!=null) return unescape(r[2]); return null; <BR>} <BR>var str ="www.abc.com/index.htm?a=1&b=1&c=测试测试"; <BR>alert(str.getQuery("a")); <BR>alert(str.getQuery("b")); <BR>alert(str.getQuery("c")); <BR></script>