Thursday, November 1, 2012

useMap

Properti HTMLObjectElement.useMap menetapkan atau mengembalikan atribut USEMAP elemen OBJECT HTML.

Sintaks:

objectObj.useMap = value objectObj.useMap

value adalah DOMString yang berisi nilai atribut NAME elemen MAP dan diawali tanda '#'.

Contoh di bawah ini mengembalikan nilai atribut USEMAP:

<OBJECT DATA="image.jpg" TYPE="image/jpg" WIDTH="300" HEIGHT="200" USEMAP="#mymap"> <MAP NAME="mymap"> <AREA HREF="A.html" SHAPE="rect" COORDS="5,5,95,195"> <AREA HREF="B.html" SHAPE="rect" COORDS="105,5,195,195"> <AREA HREF="C.html" SHAPE="rect" COORDS="205,5,295,195"> </MAP> </OBJECT> <SCRIPT TYPE="text/javascript"> var objectObj = document.getElementsByTagName("object")[0]; alert(objectObj.useMap); // "#mymap" </SCRIPT>

Contoh di bawah ini menetapkan atribut USEMAP:

<OBJECT DATA="image.jpg" TYPE="image/jpg" WIDTH="300" HEIGHT="200"> <MAP NAME="mymap"> <AREA HREF="A.html" SHAPE="rect" COORDS="5,5,95,195"> <AREA HREF="B.html" SHAPE="rect" COORDS="105,5,195,195"> <AREA HREF="C.html" SHAPE="rect" COORDS="205,5,295,195"> </MAP> </OBJECT> <SCRIPT TYPE="text/javascript"> var objectObj = document.getElementsByTagName("object")[0]; objectObj.useMap = "#mymap"; </SCRIPT>

Elemen OBJECT di atas akan menjadi:

<OBJECT DATA="image.jpg" TYPE="image/jpg" WIDTH="300" HEIGHT="200" USEMAP="#mymap"> <MAP NAME="mymap"> <AREA HREF="A.html" SHAPE="rect" COORDS="5,5,95,195"> <AREA HREF="B.html" SHAPE="rect" COORDS="105,5,195,195"> <AREA HREF="C.html" SHAPE="rect" COORDS="205,5,295,195"> </MAP> </OBJECT>