<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
var winWidth,winHeight,theLeft,theTop,theImg;
var xFlag=1,yFlag=1;
var xStep=2,yStep=1;
function movePic()
{
theImg=document.getElementById("img1").style;
winWidth=document.body.clientWidth;
winHeight=document.body.clientHeight;
theLeft=parseInt(theImg.left);
theTop=parseInt(theImg.top);
if(theLeft<=0)
xFlag=1;
if(theLeft+120>=winWidth)
xFlag=-1;
if(theTop<=0) 
yFlag=1;
if(theTop+60>=winHeight)
yFlag=-1;
theImg.left=theLeft+xFlag*xStep;
theImg.top=theTop+yFlag*yStep;
setTimeout("movePic()",50);
}
</script>
<body onload="movePic()" background="image/200602161058261301491.jpg">
<div id="img1" style="position:absolute; left:0px; top:0px; width:120px; height:60px; z-index:2;">
<a href=""><img border="0" src="image/4b1366b002000001.jpg" /></a>
</div> 
</body>
</html>
为什么setTimeout(),大概调用了7 8次
theImg=document.getElementById("img1").style;
这句就会找不到img1对象了?为什么呢?