Area href Property
Example
Change the URL of a link in an area:
document.getElementById("venus").href = "sun.htm";
Try it Yourself »
Description
The href property sets or returns the value of the href attribute of an area.
The href attribute specifies the destination of a link in an area.
Browser Support
Property | |||||
---|---|---|---|---|---|
href | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the href property:
areaObject.href
Set the href property:
areaObject.href = URL
Property Values
Value | Description |
---|---|
URL |
Specifies the hyperlink target for the area. Possible values:
|
Technical Details
Return Value: | A String, representing the URL of the link. Returns the entire URL, including the protocol (like http://) |
---|
More Examples
Example
Get the URL of a link in an area:
var x =
document.getElementById("venus").href;
Try it Yourself »
Example
Change the URL of a link in an area to an absolute URL:
document.getElementById("venus").href = "http://www.cnn.com/";
Try it Yourself »
Related Pages
HTML reference: HTML <area> href attribute
❮ Area Object