Area pathname 屬性

Area 對象參考手冊 Area 對象

定義和用法

pathname 屬性可設置或返回href屬性值中的路徑名部分。

語法

areaObject.pathname=path


流覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要流覽器都支持 pathname 屬性


提示和注釋

注意:在以下實例中, IE 和 Opera 返回 "jsref/venus.htm", 但是 Firefox, Chrome, 和 Safari 返回 "/jsref/venus.htm".


實例

實例

下麵的例子可返回 "Venus" 區域中href屬性值中的路徑名:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.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流覽器返回 &quot;jsref/venus.htm&quot;,
而Firefox, Chrome, 和 Safari流覽器返回 &quot;/jsref/venus.htm&quot;.</p>

</body>
</html>

以上實例輸出結果:

金星區域的路徑: /try/demo_source/venus.htm



Area 對象參考手冊 Area 對象