请问很多网站上的飘来飘去广告是怎么实现的?

june37 2003-01-10 02:08:49
如题!sina,163上就有很多,怎么实现的呢?
...全文
95 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
genuis 2003-01-10
  • 打赏
  • 举报
回复
又来迟一步,楼主,给我少许分先
方工 2003-01-10
  • 打赏
  • 举报
回复
<script>
document.write('<DIV id=mov6 style="POSITION: absolute; width: 10px; height: 10px"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH=80 HEIGHT=80><PARAM NAME=movie VALUE="http://www.163.net/ad/adv/netcn/netcn_100x100.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="http://www.163.net/ad/adv/netcn/netcn_100x100.swf" quality=high bgcolor=#FFFFFF WIDTH=80 HEIGHT=80 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT><img src="http://bjad.163.net/image.ng/site=www163net&channel=163mainpage&SpaceDesc=mainpage&location=moving2" width="1" height="1" border="0"></DIV>');

var xPos = 250;
var yPos = document.body.clientHeight;
var step = 1;
var delay = 20;
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
mov6.style.top = yPos;
function changePos() {
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = mov6.offsetHeight;
Woffset = mov6.offsetWidth;
mov6.style.left = xPos + document.body.scrollLeft;
mov6.style.top = yPos + document.body.scrollTop;
if (yon) {
yPos = yPos + step;
}
else {
yPos = yPos - step;
}
if (yPos < 0) {
yon = 1;
yPos = 0;
}
if (yPos >= (height - Hoffset)) {
yon = 0;
yPos = (height - Hoffset);
}
if (xon) {
xPos = xPos + step;
}
else {
xPos = xPos - step;
}
if (xPos < 0) {
xon = 1;
xPos = 0;
}
if (xPos >= (width - Woffset)) {
xon = 0;
xPos = (width - Woffset);
}
}
function start() {
mov6.visibility = "visible";
interval = setInterval('changePos()', delay);
}

start();
</script>
利而不害 2003-01-10
  • 打赏
  • 举报
回复
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>

<BODY>
<DIV id=img style="HEIGHT: 24px; LEFT: 0px; POSITION: absolute; TOP: 1582px; WIDTH: 99px">
<img src="1.jpg" width="50" height="50">
</DIV>

<SCRIPT language=JavaScript>
var xPos = 20;
var yPos = document.body.clientHeight;
var step = 1;
var delay = 30;
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
img.style.top = yPos;


function changePos() {
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = img.offsetHeight;
Woffset = img.offsetWidth;
img.style.left = xPos + document.body.scrollLeft;
img.style.top = yPos + document.body.scrollTop;

if (yon) {
yPos = yPos + step;
} else {
yPos = yPos - step;
}
if (yPos < 0) {
yon = 1;
yPos = 0;
}
if (yPos >= (height - Hoffset)) {
yon = 0;
yPos = (height - Hoffset);
}

if (xon) {
xPos = xPos + step;
}
else {
xPos = xPos - step;
}
if (xPos < 0) {
xon = 1;
xPos = 0;
}
if (xPos >= (width - Woffset)) {
xon = 0;
xPos = (width - Woffset);
}
}

function start() {
img.visibility = "visible";
interval = setInterval('changePos()', delay);
}
start();
</SCRIPT>

</BODY>
</HTML>
wssgwps 2003-01-10
  • 打赏
  • 举报
回复
在Dreamweaver中用时间轴吧,挺方便的!!!

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧