<html>
<head>
<script language="JavaScript">
function move()
{
document.getElementById("Layer1").style.left=Math.random()*500;
document.getElementById("Layer1").style.top=Math.random()*500;
setTimeout("move()",500);
}
</script>
</head>
<body onload="move()">
<div id="Layer1" style="position:absolute;left:14px;top:44px;width:150px;height:102px;z-index:1">
<a href="http://www.baidu.com">
<img src="aa.jpg" width="100" height="100">
</a>
</div>
</body>
</html>

本文介绍了一种使用JavaScript实现网页上图片随机移动的方法。通过设置定时器,页面加载时图片将在指定范围内自动改变位置,增加了网页的互动性和趣味性。
1618

被折叠的 条评论
为什么被折叠?



