ใช้ JavaScript เพื่อสร้างแผนที่รูปภาพฝั่งไคลเอ็นต์ แมปรูปภาพฝั่งไคลเอ็นต์เปิดใช้งานโดยแอตทริบิวต์ usemap สำหรับแท็ก และกำหนดโดยแท็กส่วนขยายพิเศษ
รูปภาพที่กำลังจะสร้างแผนที่จะถูกแทรกลงในหน้าโดยใช้องค์ประกอบ ตามปกติ ยกเว้นว่ามีแอตทริบิวต์พิเศษที่เรียกว่า usemap . ค่าของแอตทริบิวต์ usemap คือค่าของแอตทริบิวต์ชื่อบนองค์ประกอบ
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อสร้างแผนที่รูปภาพฝั่งไคลเอ็นต์ -
<html>
<head>
<title>Using JavaScript Image Map</title>
<script type="text/javascript">
<!--
function showTutorial(name) {
document.myform.stage.value = name
}
//-->
</script>
</head>
<body>
<form name="myform">
<input type = "text" name = "stage" size = "20" />
</form>
<!-- Create Mappings -->
<img src="/images/usemap.gif" alt="HTML Map" border="0" usemap="#tutorials"/>
<map name="tutorials">
<area shape="poly"
coords="74,0,113,29,98,72,52,72,38,27"
href="/perl/index.htm" alt="Perl Tutorial"
target="_self"
onMouseOver="showTutorial('perl')"
onMouseOut="showTutorial('')"/>
<area shape="rect"
coords="22,83,126,125"
href="/html/index.htm" alt="HTML Tutorial"
target="_self"
onMouseOver="showTutorial('html')"
onMouseOut="showTutorial('')"/>
<area shape="circle"
coords="73,168,32"
href="/php/index.htm" alt="PHP Tutorial"
target="_self"
onMouseOver="showTutorial('php')"
onMouseOut="showTutorial('')"/>
</map>
</body>
</html>