Posted on 2011-11-27 21:28
哈希 阅读(168)
评论(0) 编辑 收藏 所属分类:
Js and Jquery 常用总结
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<!--放置广告层-->
<div id="adv" style="position:absolute; left:60px; top:220px; width:100px; height:75px; z-index:2">
<a href="http://www.xinzhanedu.com">
<img src="imgs/ad.jpg"/>
</a>
<div id="close" style="position:absolute; left:79px; top:61px; width:21px; height:14px;">
<img src="imgs/close.png" style="cursor:pointer;" onClick="closeAdv()"/>
</div>
</div>
<script language="javascript">
var x=0,y=0,ypos=220,xpos=60,step=6,speed=10;
var adv=document.getElementById("adv");
function gogogo(){
adv.style.left=xpos+document.body.scrollLeft;
adv.style.top=ypos+document.body.scrollTop;
if(x==0){
//从左到右
xpos+=step;
}else
{
xpos-=step;
}
if(xpos>=document.body.clientWidth-100){
//改变方向
xpos=document.body.clientWidth-100;
x=1;
}
if(xpos<0){
xpos=0;
x=0;
}
//纵向
if(y==0){
//从左到右
ypos+=step;
}else
{
ypos-=step;
}
if(ypos>=document.body.clientHeight-75){
//改变方向
ypos=document.body.clientHeight-75;
y=1;
}
if(ypos<0){
ypos=0;
y=0;
}
}
setInterval("gogogo()",speed);
</script>
<table width="2000" height="1000">
<tr>
<td>
<img src="imgs/bg.jpg" width="1400" height="3417"/>
</td>
</tr>
</table>
</body>
</html>