UseMap Alters Background Color

[Total: 0    Average: 0/5]

This code shows how to use an image to map 4 different href links.

Body Code:

<script>
var backColor = new Array();
    backColor[0] = 'steelblue';
    backColor[1] = 'white';
    backColor[2] = 'black';
    backColor[3] = 'darkred';

function changeBG(whichColor){
  document.bgColor = backColor[whichColor];
}
</script>
<IMG SRC='http://www.js-x.com/js/pic1.gif' WIDTH=50 HEIGHT=50 usemap="#ColorChart" border="0">

<map name="ColorChart">
<area shape="rect" alt="steelblue" coords="0,0,25,25"   href="javascript:changeBG(0)">
<area shape="rect" alt="white"     coords="0,25,25,50"  href="javascript:changeBG(1)">
<area shape="rect" alt="black"     coords="25,0,50,25"  href="javascript:changeBG(2)">
<area shape="rect" alt="darkred"   coords="25,25,50,50" href="javascript:changeBG(3)">
<area shape="default">
</map>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *