• 3438阅读
  • 0回复

如何在网页中添加飘动的广告 [复制链接]

上一主题 下一主题
离线cai
 

只看楼主 倒序阅读 0楼 发表于: 2005-03-30
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body><script LANGUAGE="JavaScript">
<!-- Begin
var brOK=false;
var mie=false;
var aver=parseInt(navigator.appVersion.substring(0,1));
var aname=navigator.appName;
function checkbrOK()
{if(aname.indexOf("Internet Explorer")!=-1)
  {if(aver>=4) brOK=navigator.javaEnabled();
  mie=true;
  }
if(aname.indexOf("Netscape")!=-1)
  {if(aver>=4) brOK=navigator.javaEnabled();}
}
var vmin=2;
var vmax=5;
var vr=0.02;
var timer1;
function Chip(chipname,width,height)
{this.named=chipname;
this.vx=vmin+vmax*Math.random();
this.vy=vmin+vmax*Math.random();
this.w=width;
this.h=height;
this.xx=0;
this.yy=0;
this.timer1=null;
}
function movechip(chipname)
{
if(brOK)
{eval("chip="+chipname);
  if(!mie)
  {pageX=window.pageXOffset;
  pageW=window.innerWidth;
  pageY=window.pageYOffset;
  pageH=window.innerHeight;
  }
  else
  {pageX=window.document.body.scrollLeft;
  pageW=window.document.body.offsetWidth-22;
  pageY=window.document.body.scrollTop;
  pageH=window.document.body.offsetHeight-34;
  }

  chip.xx=chip.xx+chip.vx;
  chip.yy=chip.yy+chip.vy;

  chip.vx+=vr*(Math.random()-0.5);
  chip.vy+=vr*(Math.random()-0.5);
  if(chip.vx>(vmax+vmin)) chip.vx=(vmax+vmin)*2-chip.vx;
  if(chip.vx<(-vmax-vmin)) chip.vx=(-vmax-vmin)*2-chip.vx;
  if(chip.vy>(vmax+vmin)) chip.vy=(vmax+vmin)*2-chip.vy;
  if(chip.vy<(-vmax-vmin)) chip.vy=(-vmax-vmin)*2-chip.vy;


  if(chip.xx<=pageX)
  {chip.xx=pageX;
    chip.vx=vmin+vmax*Math.random();
  }
  if(chip.xx>=pageX+pageW-chip.w)
  {chip.xx=pageX+pageW-chip.w;
    chip.vx=-vmin-vmax*Math.random();
  }
  if(chip.yy<=pageY)
  {chip.yy=pageY;
    chip.vy=vmin+vmax*Math.random();
  }
  if(chip.yy>=pageY+pageH-chip.h)
  {chip.yy=pageY+pageH-chip.h;
    chip.vy=-vmin-vmax*Math.random();
  }

  if(!mie)
    {eval('document.'+chip.named+'.top ='+chip.yy);
    eval('document.'+chip.named+'.left='+chip.xx);
    }
  else
    {eval('document.all.'+chip.named+'.style.pixelLeft='+chip.xx);
    eval('document.all.'+chip.named+'.style.pixelTop ='+chip.yy);
    }
  chip.timer1=setTimeout("movechip('"+chip.named+"')",140);
}
}

function hide(chipname){
    if(brOK){
          eval("chip="+chipname);
          if(!mie)
                eval('document.'+chip.named+'.visibility ='+"'hide'");
          else
                eval('document.all.'+chip.named+'.style.visibility ='+"'hidden'");
    }
}

function stopme(chipname)
{if(brOK)
{
  eval("chip="+chipname);
  if(chip.timer1!=null)
  {clearTimeout(chip.timer1)}
}
}
var chip1;
function pagestart()
{checkbrOK();
chip1=new Chip("chip1",117,75);
if(brOK)
  { movechip("chip1");
  }
}
//if(brOK) {stopme('chip1');}
// End -->
</script>
<DIV id=chip1
style="height: 105; position: absolute; visibility: visible; width: 140; left: 180; top: 157">
<TABLE border=0 cellPadding=4 cellSpacing=0 class=bd width=60>
<TBODY>
<TR>
    <TD align=middle class=bg2><A class=prs1
href="http://" target=_blank><IMG border=0 class=bd src="photosource/122.gif" width="185" height="260"></A></TD>
    </TR></TBODY></TABLE></DIV>
<SCRIPT event=onload for=window language=JavaScript>
<!-- Begin
pagestart();
// End -->
</SCRIPT>


</body>
</html>



photosource/122.gif   为图片的名字
grant all privileges on *.* to 'a'@'localhost' identified by 'a' with grant option;flush privileges;
快速回复
限100 字节
 
上一个 下一个