HTML DOM Image useMap 屬性
定義和用法
useMap 屬性可設置或者返回圖片的usemap 屬性的值。
usemap 屬性指定了一個圖片的客戶端圖像映射(一個可點擊區域的圖片映射)。
usemap屬性與map元素名稱的屬性相關,兩者可以創建圖像和地圖之間的關聯。
語法
imageObject.useMap=value
useMap 屬性可以是以下值:
值 | 描述 |
---|---|
#mapname | 一个哈希字符("#")加上map元素的名称 |
瀏覽器支持
所有主要瀏覽器都支持useMap 屬性
實例
實例
返回客戶端圖片映射的usemap屬性值:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
</head>
<body>
<img id="planets" src="planets.gif" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="The planet Venus" href="venus.htm">
</map>
<p>usemap属性的值:
<script>
document.write(document.getElementById("planets").useMap);
</script>
</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
</head>
<body>
<img id="planets" src="planets.gif" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="The planet Venus" href="venus.htm">
</map>
<p>usemap属性的值:
<script>
document.write(document.getElementById("planets").useMap);
</script>
</p>
</body>
</html>
嘗試一下»
Image對象