Area pathname attribute

Definition and usage

pathname Attribute sets or returns href attribute value of the path name part.

href The attribute specifies the destination of the link in 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 pathname attribute:

areaObject.pathname

设置 pathname 属性:

areaObject.pathname = path

属性值

描述
path 规定 URL 的路径名。

技术细节

返回值: 字符串值,表示 URL 的路径名。

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持