[JS]URLParser-html页面参数获取类
URLParser类代码
/* @class: URLParser */ URLParser = function(sUrl){ this._init(sUrl); } URLParser.prototype._init=function(sUrl){ this._url = sUrl || document.location.href; } URLParser.prototype.getDomain = function(){ if (this._url.match(new RegExp('^(([a-z]+)://([^\\/]+)\/?)(.*)', 'i'))){ return RegExp.$1; }else{ return null; } } URLParser.prototype.getParameter = function(sName){ if (this._url.match(new RegExp("(&|\\u003F)" + sName + "=([^&]*)(&|$)"))){ return RegExp.$2; }else{ return null; } }
?