Area href Property
Example
Change the URL of a link in an area:
document.getElementById("venus").href = "sun.htm";
Try it yourself »
Definition and Usage
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
The href property is supported in all major browsers.
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;
The result of x will be:
http://www.w3schools.com/jsref/venus.htm
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