Tuesday, December 18, 2012

coords

Properti HTMLAnchorElement.coords menetapkan atau mengembalikan atribut COORDS elemen A HTML.

Sintaks:

anchorObj.coords = value anchorObj.coords

value adalah DOMString yang berisi daftar nilai-nilai pembentuk koordinat area klik.

Contoh di bawah ini menetapkan atribut COORDS:

<OBJECT DATA="image.png" USEMAP="#mymap" TYPE="image/png" TITLE="Site map" WIDTH="300" HEIGHT="200"> <MAP NAME="mymap"> <UL> <LI><A TITLE="Visit to A.html" HREF="#" SHAPE="rect">visit...</A></LI> <LI><A TITLE="Visit to B.html" HREF="#" SHAPE="rect">visit...</A></LI> <LI><A TITLE="Visit to C.html" HREF="#" SHAPE="rect">visit...</A></LI> </UL> </MAP> </OBJECT> <SCRIPT TYPE="text/javascript"> var anchorObj1 = document.getElementsByTagName("a")[0]; var anchorObj2 = document.getElementsByTagName("a")[1]; var anchorObj3 = document.getElementsByTagName("a")[2]; anchorObj1.coords = "5,5,95,195"; anchorObj2.coords = "105,5,195,195"; anchorObj3.coords = "205,5,295,195"; </SCRIPT>

Sehingga semua elemen A terlihat seperti:

<UL> <LI><A TITLE="Visit to A.html" HREF="#" SHAPE="rect" COORDS="5,5,95,195">visit...</A></LI> <LI><A TITLE="Visit to B.html" HREF="#" SHAPE="rect" COORDS="105,5,195,195">visit...</A></LI> <LI><A TITLE="Visit to C.html" HREF="#" SHAPE="rect" COORDS="205,5,295,195">visit...</A></LI> </UL>