得到参数可以用这个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 str = "www.google.com/index.htm?a=1&b=1&c=Split实例"; alert(str.getQuery("a")); alert(str.getQuery("b")); alert(str.getQuery("c")); */
location.search
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = this.substr(this.indexOf("\?")+1).match(reg);
if (r!=null) return unescape(r[2]); return null;
}
/*使用方法
var str = "www.google.com/index.htm?a=1&b=1&c=Split实例";
alert(str.getQuery("a"));
alert(str.getQuery("b"));
alert(str.getQuery("c"));
*/