Change the destination (URL) of a link:
The href property sets or returns the value of the href attribute of a link.
The href attribute specifies the destination of a link.
The href property is supported in all major browsers.
Return the href property:
Set the href property:
Value | Description |
---|---|
URL |
Specifies the URL of the link. Possible values:
|
Return Value: | A String, representing the URL of the link. Returns the entire URL, including the protocol (like http://) |
---|
Get the URL of a link:
The result of x will be:
Another example of how to get the URL of a link (a relative URL):
HTML reference: HTML <a> href attribute