Area pathnameProperty
Area Object
Definition and Usage
The pathname property sets or returns the pathname part of the href attribute value.
Syntax
areaObject.pathname=path
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the pathname property
Tips and Notes
Note:In the example below, IE and Opera return "jsref/venus.htm", but Firefox, Chrome, and Safari return "/jsref/venus.htm".
Example
Example
The following example returns the pathname of the href attribute value in the "Venus" area:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
</head>
<body>
<img src="planets.gif.html"width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="venus.htm.html">
</map>
<p>The path of the Venus area:
<script>
document.write(document.getElementById('venus').pathname);
</script>
</p>
<p><b>Note:</b> IE and Opera browsers return "jsref/venus.htm",
while Firefox, Chrome, and Safari browsers return "/jsref/venus.htm".</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
</head>
<body>
<img src="planets.gif.html"width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="venus.htm.html">
</map>
<p>The path of the Venus area:
<script>
document.write(document.getElementById('venus').pathname);
</script>
</p>
<p><b>Note:</b> IE and Opera browsers return "jsref/venus.htm",
while Firefox, Chrome, and Safari browsers return "/jsref/venus.htm".</p>
</body>
</html>
The output of the above example:
The path of the Venus area: /try/demo_source/venus.htm
Try it yourself »
Area Object Other Extensions