<html>
<head>
<script language=javascript>
var gox=1;
var goy=1;
function move()
{
var w=window.document.body.offsetWidth;
var h=window.document.body.offsetHeight;
var speedx=20;
var speedy=Math.tan(Math.PI/4)*speedx;
var x = document.getElementById("Layer1").style.left;
var y = document.getElementById("Layer1").style.top;
if(parseInt(x)+150>w||parseInt(x)<0)
gox = -gox;
if(parseInt(y)+100>h || parseInt(y)<0)
goy = -goy;
document.getElementById("Layer1").style.left = parseInt(x) + speedx * gox;
document.getElementById("Layer1").style.top = parseInt(y) + speedy * goy;
setTimeout("move()",800);
}
</script>
</head><body onload="move()">
<DIV id="Layer1" style="position:absolute;left:Opx;top:Opx;width:150px;height:100px;z-index:1"><a href="http://www.sina.com"><img src="1.jpg"width="150" height="100" border="0"></a></DIV>
<h2>飘啊飘</h2>
<p></p>
</body>
</html>
<html>
<head>
<script language=javascript>
var gox=1;
var goy=1;
var tid=null;
function move()
{
var w=window.document.body.offsetWidth;
var h=window.document.body.offsetHeight; var speedx=20;
var speedy=Math.tan(Math.PI/4)*speedx;
var x = document.getElementById("Layer1").style.left;
var y = document.getElementById("Layer1").style.top;
if(parseInt(x)+150> w || parseInt(x) <0) gox = -gox;
if(parseInt(y)+100> h || parseInt(y) <0) goy = -goy;
document.getElementById("Layer1").style.left = parseInt(x) + speedx * gox;
document.getElementById("Layer1").style.top = parseInt(y) + speedy * goy;
if(tid!=null) clearTimeOut(tid);
setTimeout("move()",100);
}
</script>
</head> <body onload="move()">
<DIV id="Layer1" style="position:absolute;left:0px;top:0px;width:150px;height:100px;z-index:1"> <a href="http://www.sina.com"> <img src="1.jpg"width="150" height="100" border="0"> </a> </DIV>
<h2> 飘啊飘 </h2>
<p> </p>
</body>
</html>