Latest web development tutorials

HTML DOM Area pathname property

Area Object Reference Area objects

Definition and Usage

pathname property sets or returns the href attribute value pathname components.

grammar

areaObject.pathname=path


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support pathname property


Tips and Notes

Note: In the following example, IE and Opera returns "jsref / venus.htm", but Firefox, Chrome, and Safari return "/jsref/venus.htm".


Examples

Examples

The following example returns "Venus" in the href attribute value zone pathname:

<!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浏览器返回 &quot;jsref/venus.htm&quot;,
而Firefox, Chrome, 和 Safari浏览器返回 &quot;/jsref/venus.htm&quot;.</p>

</body>
</html>

Examples of the above output:

金星区域的路径: /try/demo_source/venus.htm

try it"


Area Object Reference Area objects