获取主机名

var hostname = location.hostname;

获取端口号

var port = location.port;

获取主机名+端口号

var host = location.host;