• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
小不点儿大的由我做主!
流年似水!
博客园    首页    新随笔    联系   管理    订阅  订阅

利用Ajax实现的广告流动条的两种方式

一.实现飘浮广告:

<!DOCTYPE HTML PUBLIC "-//-W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>test</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<script language="javascript" type="text/javascript">
var x1=10;
var y1=-10;
function fly()
{
flypic.style.top=parseInt(flypic.style.top) -y1;
flypic.style.left=parseInt(flypic.style.left) -x1;
if(parseInt(flypic.style.top)<0)
{y1=-y1;}
if(parseInt(flypic.style.top)>300)
{y1=-y1;}
if(parseInt(flypic.style.left)<0)
{x1=-x1;}
if(parseInt(flypic.style.left)>630)
{x1=-x1;}
window.setTimeout("fly()",300);
}
</script>
</head>
<body onload="fly()">
<div id="flypic" style="position:absolute;top:20;left:40">
<img src="Blue hills.jpg" alt="">
</div>
</body>
</html>

二.实现随滚动条滚动的漂浮广告

<!DOCTYPE HTML PUBLIC "-//-W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>test</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<script language="javascript" type="text/javascript">
function moveIt()
{
truck.style.top=document.body.scrollTop+parseInt(document.body.clientHeight)- 90;
window.setTimeout('moveIt()',1000);
}
</script>
</head>

<body>
<body BGCOLOR="#FFF" TEXT="#000" link="#0000ff" Vlink="#660099" onload="moveIt()">
<div id="truck" style="position:relative;top:30px;left:500px;width:40px;height:16px">
<img src="Blue hills.jpg">
</div>
</body>
</html>

(图片自己可以找一张)

posted @ 2008-04-09 15:44  小不点儿大的由我做主!  阅读(139)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3