Location hostname 属性

定义和用法
hostname 属性是一个可读可写的字符串,可设置或返回当前 URL 的主机名。
语法
location.hostname
浏览器支持
所有主要浏览器都支持 hostname 属性
实例代码
返回当前URL的主机名:
<script>
document.write(location.hostname);
</script>
document.write(location.hostname);
</script>
以上实例输出结果:
