Properti HTMLAreaElement.href
menetapkan atau mengembalikan atribut HREF elemen AREA HTML.
Sintaks:
areaObj.href = value
areaObj.href
value adalah DOMString yang berisi full URIs (misal: 'http://www.example.com/'), atau relative URIs (misal: 'foo.html' atau '../foo/').
Contoh di bawah ini mengembalikan nilai atribut HREF:
<MAP NAME="mymap">
<AREA ID="areaID" SHAPE="circle" COORDS="124,58,8" HREF="http://www.example.com/" TITLE="Visit to Example.com" ALT="Site map">
</MAP>
<IMG WIDTH="145" HEIGHT="126" SRC="image.png" USEMAP="#mymap">
<SCRIPT TYPE="text/javascript">
var areaObj = document.getElementById("areaID");
alert(areaObj.href); // "http://www.example.com/"
</SCRIPT>
Contoh di bawah ini menetapkan atribut HREF:
<MAP NAME="mymap">
<AREA ID="areaID" SHAPE="circle" COORDS="124,58,8" ALT="Site map" TITLE="Visit to Example.com">
</MAP>
<IMG WIDTH="145" HEIGHT="126" SRC="image.png" USEMAP="#mymap">
<SCRIPT TYPE="text/javascript">
var areaObj = document.getElementById("areaID");
areaObj.href = "http://www.example.com/";
</SCRIPT>
Elemen AREA di atas akan menjadi:
<AREA ID="areaID" SHAPE="circle" COORDS="124,58,8" ALT="Site map" TITLE="Visit to Example.com" HREF="http://www.example.com/">