HTML DOM Area pathname 屬性
定義和用法
pathname 屬性可設置或返回href屬性值中的路徑名部分。
語法
areaObject.pathname=path
瀏覽器支持
所有主要瀏覽器都支持pathname 屬性
提示和註釋
注意:在以下實例中, IE和Opera返回"jsref/venus.htm",但是Firefox, Chrome,和Safari返回"/jsref/venus.htm".
實例
實例
下面的例子可返回"Venus" 區域中href屬性值中的路徑名:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</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>金星区域的路径:
<script>
document.write(document.getElementById('venus').pathname);
</script>
</p>
<p><b>注意:</b> IE和Opera浏览器返回 "jsref/venus.htm",
而Firefox, Chrome, 和 Safari浏览器返回 "/jsref/venus.htm".</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</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>金星区域的路径:
<script>
document.write(document.getElementById('venus').pathname);
</script>
</p>
<p><b>注意:</b> IE和Opera浏览器返回 "jsref/venus.htm",
而Firefox, Chrome, 和 Safari浏览器返回 "/jsref/venus.htm".</p>
</body>
</html>
以上實例輸出結果:
金星区域的路径: /try/demo_source/venus.htm
嘗試一下»
Area對象