`
lizhuang
  • 浏览: 889216 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

简单的浮动广告

阅读更多
<html>
<head>
<!--
在网页中,浏览器窗口的左上角默认为原点(0,0)位置。HTML 对象的起点位置坐标(x,y)一般分别使用left 和top属性表示,分别代表该对象的左边距和上边距。
Math对象的random()方法产生0-1的随机数,Layer1层的左边距和上边距的值是随机的所以产生了随机移动的效果。
-->
<script language=JavaScript>
function move(){
document.getElementById("Layer1").style.left = Math.random()*500;
document.getElementById("Layer1").style.top = Math.random()*500;
setTimeout("move()",800);
}
</script>
</head>
<body onload="move()">
<div id="Layer1" style="position:absolute;left:14px;top:44px;width:150px; height:102px; z-index:1; bgcolor:red;">
<a href="http://amazon.com">
<img src="a.jpg" width="150" height="100"/>
</a>
</div>
<h2>随机漂浮广告</h2>
</body>
</html>
0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics