Course Recommendation:

Area hash attribute

Definition and Usage hash This attribute sets or returns href attribute value

Anchor part This attribute specifies the destination of the link in the defined area.

The anchor part is the part after the hash (#) in the URL.

Note:Do not include the hash (#) when this attribute is used to set the anchor part.

See also:

JavaScript Reference Manual:location.hash attribute

Example

Example 1

Return the anchor part of the URL of a specific area in the image map:

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

Try it yourself

Example 2

Change the anchor part of a specific area in the image map:

document.getElementById("venus").hash = "newhashvalue";

Try it yourself

Syntax

Return hash attribute:

areaObject.hash

Set hash attribute:

areaObject.hash = anchorname

Attribute Value

Value Description
anchorname Specifies the anchor part of the URL.

Technical Details

Return Value: A string value representing the anchor part of the URL, including the hash (#).

Browser Support

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