Area host 屬性

定義和用法
host 屬性克設(shè)置或者返回 href 屬性值的 主機(jī)名:端口 部分。
語(yǔ)法
areaObject.host=hostname:port
瀏覽器支持
所有主要瀏覽器都支持 host 屬性
提示和注釋
注意: 如果在URL中端口部分沒(méi)有指定,或者端口為80(默認(rèn)值),一些瀏覽器將不會(huì)顯示端口部分。
實(shí)例
實(shí)例
下面的例子可返回 "Venus" 區(qū)域的主機(jī)名和端口:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool教程(w3cschool.cn)</title>
</head>
<body>
<img src="planets.gif" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
<p>金星區(qū)域的 hostname:port:
<script>
document.write(document.getElementById('venus').host);
</script>
</p>
<p><b>注意:</b>如果沒(méi)有指定端口部分的URL,或者是80(默認(rèn)),一些瀏覽器將不會(huì)顯示端口的部分。</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool教程(w3cschool.cn)</title>
</head>
<body>
<img src="planets.gif" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
<p>金星區(qū)域的 hostname:port:
<script>
document.write(document.getElementById('venus').host);
</script>
</p>
<p><b>注意:</b>如果沒(méi)有指定端口部分的URL,或者是80(默認(rèn)),一些瀏覽器將不會(huì)顯示端口的部分。</p>
</body>
</html>
以上實(shí)例輸出結(jié)果:
金星區(qū)域的 hostname:port: m.o2fo.com
嘗試一下 ?

更多建議: