如何在 JavaScript 中獲取 usemap 屬性的值?
為了使用 JavaScript 獲取連結的 usemap 屬性的值,請使用 useMap 屬性。usemap 屬性用於指示文件是 html (text/html) 或 css (text/css) 等。
客戶端影像貼圖由 <img /> 標籤的 usemap 屬性啟用,並且由特殊的 <map> 和 <area> 擴充套件標籤定義。形成此貼圖的影像使用 <img /> 元素插入頁面,就像通常那樣,只是它帶有稱為 usemap 的額外的屬性。
示例
你可以嘗試執行以下程式碼以獲取連結的 usemap 屬性的值 −
<!DOCTYPE html>
<html>
<body>
<img id="myid" src = "/images/html.gif" alt = "HTML Map" border = "0" usemap = "#html"/>
<map name = "html">
<area id="myarea" shape = "circle" coords = "154,150,59" href = "about.htm?id=company" alt = "Team" target = "_self" >
</map>
<script>
var myVal = document.getElementById("myid").useMap;
document.write("<br>Usemap value: "+myVal);
</script>
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP