HTML DOM host 屬性
定義和用法
host 屬性是一個可讀可寫的字符串,可設(shè)置或返回當前 URL 的主機名稱和端口號。
語法
location.host
實例
假設(shè)當前的 URL 是: http://example.com:1234/test.htm#part2:
<html>
<body>
<script type="text/javascript">
document.write(location.host
);
</script>
</body>
</html>
輸出:
example.com:1234