'noHref' Example : Image Map « HTML « JavaScript DHTML






'noHref' Example

 
    
<html>
<head>
<script language="JavaScript">
    function function11() {
        document.all.area1.coords = "0, 0, 100, 50";
    }
    function function12() {
        document.all.area2.coords = "100, 0, 200, 50"; 
        document.all.area2.noHref = 'true';
    }
    function function13() {
        document.all.area3.coords = "0, 50, 100, 100";
    }
    function function14() {
        document.all.area4.coords = "100, 50, 200, 100";
    }
    function function15() {
        document.getElementById("area1").coords = "0, 0, 0, 0";
        document.getElementById("area2").coords = "0, 0, 0, 0";
        document.getElementById("area3").coords = "0, 0, 0, 0";
        document.getElementById("area4").coords = "0, 0, 0, 0";
    }
</script>
</head>
<body>
<img src="yourimage.gif" id="myImg" alt="" width="200" height="100" usemap="#myMap2"> 
<map name="myMap2"> 
    <area id="area1" 
          shape="rect" 
          href="http://www.java2s.com" 
          alt="java2s.com" 
          onClick="return false">
    <area id="area2" 
          shape="rect" 
          href="http://www.java2s.com" nohref="true" 
          alt="java2s.com home page" 
          onClick="return false">
    <area id="area3" 
          shape="rect" 
          href="http://www.java2s.com" 
          alt="java2s home page" 
          onClick="return false">
    <area id="area4" 
          shape="rect" 
          href="http://www.java2s.com" 
          alt="java2s.com" 
          onClick="return false">
</map>
<br>
<input type="button" value="Make area 1 active" onClick="function11();">
<input type="button" value="Make area 2 active" onClick="function12();">
<input type="button" value="Make area 3 active" onClick="function13();">
<input type="button" value="Make area 4 active" onClick="function14();">
<button onclick="function15();">Restore areas to inactive</button>
<button onclick="alert(myImg.isMap);">IS MAP</button>
<button onclick="alert(area2.noHref);">noHref for Area 2</button>
</body>
</html> 

    
      
        
  








Related examples in the same category

1.Image map shape
2.'coords' Example
3.isMap and useMap Example
4. Image Map Event Handling
5.Creating the Image Map
6.Methods and Properties of the Area Object
7.Assign different location href for different part of an image