<!DOCTYPE html>
<html>
<body>
<img src="planets.gif" width="145" height="126" usemap="#myMap">
<p>单击按钮创建一个图像映射和一个带有“venus.htm”链接的区域元素。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.createElement("MAP");
x.setAttribute("id", "myMap");
x.setAttribute("name", "myMap");
document.body.appendChild(x);
var y = document.createElement("AREA");
y.setAttribute("href", "venus.htm");
y.setAttribute("shape", "circle");
y.setAttribute("coords", "124,58,8");
document.getElementById("myMap").appendChild(y);
document.getElementById("demo").innerHTML = "图像映射已创建,您现在可以单击图像中的金星区域。";
}
</script>
</body>
</html>