//获取浏览器url参数 var methods ={ getQueryString: function (name) { var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'); var r = location.search.substr(1).match(reg); if (r != null) { return unescape(r[2]); } return null; } }; //调用方法:window.location网址后加上 url?userid=11&name=n1 alert(methods.getQueryString('userid'));