方法一:
<script type="text/javascript">
<!--
function Request(strName){
var strHref = "www.QQView.com/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[i].split("=");
if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
}
return "";
}
alert(Request("a"));
alert(Request("b"));
alert(Request("c"));
//-->
</script>
方法二:
<script type="text/javascript">
<!--
String.prototype.getQuery = function(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.QQView.com/index.htm?a=aaa&b=bbb&c=ccc";
alert(strHref.getQuery("a"));
alert(strHref.getQuery("b"));
alert(strHref.getQuery("c"));
//-->
</script>
方法三:
<SCRIPT language=javascript>
function geturl(){
var srcc = window.location; //得到地址栏连接
srcc = srcc.toString() //转换成string类型,可以省略
start = srcc.indexOf("#"); //返回"?"在字串中第一次出现的位置
end = srcc.length; //字串的长度
var str;
str=srcc.substring(start+1,end); //得到部分字串
this.tciframe.location.href="地址?"+str;;
}
</SCRIPT>