所以我已经翻译了你在你的问题中发布的那个可怕的行(我想这就是为什么人们没有考虑你的问题)并且我已经为你想出了这个例子,当然你仍然需要正确地实现它在您的页面中。
CSS
myImage {
padding-right: 10px;
}
HTML
<div id="topdiv"></div>
Javascript
var topdiv = document.getElementById('topdiv'),
map,
tempVar;
function area1() {
alert("you clicked in area1");
}
function area2() {
alert("you clicked in area2");
}
function area3() {
alert("you clicked in area3");
}
function pointerOn(evt) {
evt.target.style.cursor = "hand";
}
function pointerOff(evt) {
evt.target.style.cursor = "auto";
}
map = document.createElement("map");
map.name = "socialmap";
tempVar = document.createElement("area");
tempVar.shape = "rect";
tempVar.coords = "0,0,99,50";
tempVar.href = "#";
tempVar.addEventListener("click", area1, false);
tempVar.addEventListener("mouseover", pointerOn, false);
tempVar.addEventListener("mouseout", pointerOff, false);
map.appendChild(tempVar);
tempVar = document.createElement("area");
tempVar.shape = "rect";
tempVar.coords = "100,0,199,50";
tempVar.href = "#";
tempVar.addEventListener("click", area2, false);
tempVar.addEventListener("mouseover", pointerOn, false);
tempVar.addEventListener("mouseout", pointerOff, false);
map.appendChild(tempVar);
tempVar = document.createElement("area");
tempVar.shape = "rect";
tempVar.coords = "200,0,299,50";
tempVar.href = "#";
tempVar.addEventListener("click", area3, false);
tempVar.addEventListener("mouseover", pointerOn, false);
tempVar.addEventListener("mouseout", pointerOff, false);
map.appendChild(tempVar);
topdiv.appendChild(map);
tempVar = document.createElement("img");
tempVar.className = "myImage";
tempVar.src = "http://i860.photobucket.com/albums/ab165/ATnightshift/image001.gif";
tempVar.useMap = "#socialmap";
topdiv.appendChild(tempVar);
在jsfiddle 上