HTML DOM Area hostname 屬性
定義和用法
hostname 屬性可設置或返回href 屬性值得主機名部分。
語法
areaObject.hostname=hostname
瀏覽器支持
所有主要瀏覽器都支持hostname 屬性
實例
實例
下面的例子可返回圖像映射中"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>Venus 区域的主机名称:
<script>
document.write(document.getElementById('venus').hostname);
</script>
</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>Venus 区域的主机名称:
<script>
document.write(document.getElementById('venus').hostname);
</script>
</p>
</body>
</html>
以上實例輸出結果:
Venus 区域的主机名称: www.w3big.com
嘗試一下»
Area對象