HTML DOM Area host 屬性
定義和用法
host屬性克設置或者返回href屬性值的主機名:端口部分。
語法
areaObject.host=hostname:port
瀏覽器支持
所有主要瀏覽器都支持host 屬性
提示和註釋
注意:如果在URL中端口部分沒有指定,或者端口為80(默認值),一些瀏覽器將不會顯示端口部分。
實例
實例
下面的例子可返回"Venus" 區域的主機名和端口:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</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>金星区域的 hostname:port:
<script>
document.write(document.getElementById('venus').host);
</script>
</p>
<p><b>注意:</b>如果没有指定端口部分的URL,或者是80(默认),一些浏览器将不会显示端口的部分。</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</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>金星区域的 hostname:port:
<script>
document.write(document.getElementById('venus').host);
</script>
</p>
<p><b>注意:</b>如果没有指定端口部分的URL,或者是80(默认),一些浏览器将不会显示端口的部分。</p>
</body>
</html>
以上實例輸出結果:
金星区域的 hostname:port: www.w3big.com
嘗試一下»
Area對象