还有一种稍有些复杂的取域名的方法,也是过滤了文件夹名,文件名,参数……
var getHost = function(url)
{
var host = "null";
if(typeof url == "undefined"|| null == url)
{
url = window.location.href;
}
var regex = /.*\:\/\/([^\/]*).*/;
var match = url.match(regex);
if(typeof match != "undefined" && null != match)
{
host = match[1];
}
return host;
}
···
···