1 function getHost(url) {
2 var host = "null";
3 if(typeof url == "undefined"|| null == url) {
4 url = window.location.href;
5 }
6 var regex = /^\w+\:\/\/([^\/]*).*/;
7 var match = url.match(regex);
8 if(typeof match != "undefined" && null != match) {
9 host = match[1];
10 }
11 return host;
12 }