
要在 JavaScript 中获取某个区域的 href 属性的路径名部分,请使用 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>

