Area hostname 屬性

定義和用法
hostname 屬性可設(shè)置或返回 href 屬性值得主機(jī)名部分。
語(yǔ)法
areaObject.hostname=hostname
瀏覽器支持
所有主要瀏覽器都支持 hostname 屬性
實(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>Venus 區(qū)域的主機(jī)名稱(chēng):
<script>
document.write(document.getElementById('venus').hostname);
</script>
</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>Venus 區(qū)域的主機(jī)名稱(chēng):
<script>
document.write(document.getElementById('venus').hostname);
</script>
</p>
</body>
</html>
以上實(shí)例輸出結(jié)果:
Venus 區(qū)域的主機(jī)名稱(chēng): m.o2fo.com
嘗試一下 ?

更多建議: