方法一(推荐)
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null)return unescape(r[2]);
return null;
}
调用
var params= GetQueryString(params);
方法二
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 =this.location.href;
调用:
params =strHref.getQuery(params);