案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<h3>演示如何访问 MAP 元素</h3>
6
7
<img src="/img/eg_planets.jpg" border="0" usemap="#myMap" alt="Planets" />
8
9
<p>点击按钮来创建 IMAGE-MAP 以及链接到 "venus.htm" 的 AREA 元素:</p>
10
11
<p id="demo"></p>
12
13
<button onclick="myFunction()">试一下</button>
14
15
<script>
16
function myFunction()
17
{
18
var x = document.createElement("MAP");
19
x.setAttribute("id", "myMap");
20
x.setAttribute("name", "myMap");
21
document.body.appendChild(x);
22
23
var y = document.createElement("AREA");
24
y.setAttribute("href", "/example/html/venus.html");
25
y.setAttribute("shape", "circle");
26
y.setAttribute("coords", "180,139,14");
27
document.getElementById("myMap").appendChild(y);
28
29
document.getElementById("demo").innerHTML = "已创建 MAP,现在您可以在图像中点击 venus 区域。";
30
}
31
</script>
32
33
</body>
34
</html>
35