日期:2014-05-17 浏览次数:20631 次
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; } }
?