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