Javascript examples for DOM HTML Element:Area
The href property sets or gets the value of the href attribute of an area.
The href attribute sets the destination of a link in an area.
Set the href property with the following Values
Value | Description |
---|---|
URL | Sets the hyperlink target for the area. |
Possible values for href:
A String, representing the entire URL, including the protocol (like http://)
The following code shows how to Change the URL of a link in an area:
<!DOCTYPE html> <html> <body> <img src="http://java2s.com/resources/a.png" width="145" height="126" usemap="#myMap"> <map name="myMap"> <area id="myId" shape="circle" coords="125,60,10" alt="Venus" href="venus.htm"> </map>//from w ww. j av a 2 s . c om <button onclick="myFunction()">change the value of the href attribute</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myId").href = "sun.htm"; document.getElementById("demo").innerHTML = "The link now goes to sun.htm."; } </script> </body> </html>