案例:HTML DOM案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
function shakeleft()
5
{
6
document.getElementById('image').style.position="relative"
7
document.getElementById('image').style.left="3"
8
timer=setTimeout("shakeright()",10)
9
}
10
11
function shakeright()
12
{
13
document.getElementById('image').style.left="0"
14
timer=setTimeout("shakeleft()",10)
15
}
16
17
function stoptimer()
18
{
19
clearTimeout(timer)
20
}
21
</script>
22
</head>
23
24
<body>
25
<b>请把鼠标移动到图像上,会看到它在摇动:)</b><br />
26
<img id="image" src="/img/eg_smile.gif"
27
onmouseover="shakeleft()"
28
onmouseout="stoptimer()" />
29
</body>
30
31
</html>
32