Course recommendation:

Area pathname attribute

Definition and usage pathname Attribute sets or returns href attribute value

The pathname part of This attribute specifies the destination of the link within the area.

Note:In the following example:

  • IE 9 and earlier versions return "jsref/venus.html"
  • IE 10+, Firefox, Opera, Chrome, and Safari return "/jsref/venus.html"

Example

Example 1

Return the URL path of the specific area in the image map:

var x = document.getElementById("venus").pathname;

Try it yourself

Example 2

Change the URL path of the specific area in the image map:

document.getElementById("venus").pathname = "somenewpathname";

Try it yourself

Syntax

Return the pathname attribute:

areaObject.pathname

Set pathname attribute:

areaObject.pathname = path

Attribute Value

Value Description
path Specifies the pathname of the URL.

Technical Details

Return Value: A string value representing the pathname of the URL.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support