【www.gdgbn.com--js教程】

js 获取域名
function gethost(url){
 if(url==null || url==""){
  return ""; 
 }
 var regex = /.*://([^/]*).*/;
 var match = url.match(regex);
 if(typeof match != "undefined" && null != match)
 {
   host = match[1];
 } 
 return host;
}

本文来源:http://www.gdgbn.com/wangyezhizuo/28982/