如何使用 JavaScript 查詢和顯示 area 的 href 屬性的路徑部分?
要獲取 JavaScript 中 area 的 href 屬性的路徑部分,請使用 pathname 屬性。
示例
您可以嘗試執行以下程式碼來顯示 pathname 部分。
<!DOCTYPE html>
<html>
<body>
<img 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" target = "_self" >
</map>
<script>
var x = document.getElementById("myarea").pathname;
document.write("<br>Pathname: "+x);
</script>
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP