<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function chg(map)
{
var obj = document.getElementById('img1');
obj.useMap = map;
alert("当前usemap是:"+obj.useMap);
}
</script>
</head>
<body>
<img src="tp1.jpg" alt="产品分类查询" name="img1" width="441" height="181" border="0" usemap="#Map" id="img1" / > 
<map name="Map" id="Map" >
<area shape="rect" onclick="chg('#Map2');return false;" coords="250,129,413,162" href="#" / >
</map>
<map name="Map2" id="Map2" >
<area shape="rect" onclick="chg('#Map');return false;" coords="7,9,129,47" href="#" / >
</map >
</body>
</html>

解决方案 »

  1.   

    usemap="#Map" id="img1" 
    try:
    document.getElementById("img1").setAttribute("usemap","#Map1");
      

  2.   

    <MAP NAME="map1">
    <AREA NAME="area1" COORDS="0,0,40,40" HREF="doc1.htm" TARGET="frame1">
    <AREA NAME="area2" COORDS="40,0,80,40" HREF="doc2.htm" TARGET="frame1">
    </MAP>
    <MAP NAME="map2">
    <AREA NAME="area3" COORDS="10,40,40,80" HREF="doc3.htm"
    TARGET="frame1">
    <AREA NAME="area4" COORDS="40,40,80,80" HREF="doc4.htm"
    TARGET="frame1">
    </MAP>
    :  
    <IMG USEMAP="#map1" ID=idImg SRC="http://www.google.cn/intl/zh-CN/images/logo_cn.gif" width="286" height="110">
    :  
    <input type=button value="change maps" onclick="idImg.useMap='#map2'"/>
      

  3.   

    alert(document.getElementById("img1").usemap.toString());
    显示是为空或不是对象
      

  4.   

    好了,原来是useMap的M要大写的问题,谢谢大家