浮动广告代码(转)

 

var brOK=false;
var mie=false;
var vmin=2;
var vmax=5;
var vr=1;
var timer1;
var chinazads;
var isflash=0;    file://是否为FLASH文件的漂浮 1=是 0=否
var pic="http://www.yj-studio.com/html/link/yj-studio.gif";   file://图片的地址
var alt="支持本站,请点击广告赞助商"; file://鼠标放在图片上时显示的提示文字
var url="../AJZ20.Web/WaitTransactMatter/ShowSMasterClew.aspx";  file://图片链接的地址
var flashurl="/AI/EQIFA.swf";  file://FLASH文件的路径
var Wimg=120;    file://图像的宽度
var Himg=120;    file://图像的高度
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-100;                   file://100数值修改,应该图片的大小加上浏览器边框,这样就能折回
   pageW=window.document.body.offsetWidth-8;
   pageY
=window.document.body.scrollTop;
   pageH
=window.document.body.offsetHeight;
  }

  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.xx>=680)
  
{
   chip.xx
=chip.xx-20;
   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+"')",80);
 }

}


function stopme(chipname)
{
 
if(brOK)
 
{
  eval(
"chip="+chipname);
  
if(chip.timer1!=null)
  
{
   clearTimeout(chip.timer1)
  }

 }

}


function chinazads()
{
 
if(navigator.appName.indexOf("Internet Explorer")!=-1)
 
{
  
if(parseInt(navigator.appVersion.substring(0,1))>=4) brOK=navigator.javaEnabled();mie=true;
 }

 
if(navigator.appName.indexOf("Netscape")!=-1)
 
{
  
if(parseInt(navigator.appVersion.substring(0,1))>=4) brOK=navigator.javaEnabled();
 }

 chinazads.named
="chinazads";
 chinazads.vx
=vmin+vmax*Math.random();
 chinazads.vy
=vmin+vmax*Math.random();
 chinazads.w
=1;
 chinazads.h
=1;
 chinazads.xx
=0;
 chinazads.yy
=0;
 chinazads.timer1
=null;
 movechip(
"chinazads");
}


document.write('
<div id="chinazads" style="height:49px;left:178px;position:absolute;top:1237px;width:70px; z-index:1000">');
if (isflash>0)
{
document.write(
"<EMBED src='" + flashurl + "' quality=high  WIDTH='" + Wimg + "' HEIGHT='" + Himg + "' TYPE='application/x-shockwave-flash'></EMBED>");
}

else
{
//document.write("<a href='" + url + "'  target=_blank onmouseover=stopme('chinazads'); onmouseout=movechip('chinazads');>");
//
document.write("<img src='" + pic + "' alt='" + alt + "' border=0 width='" + Wimg + "' height='" + Himg + "' ></a>");
document.write("<img src='" + pic + "' alt='" + alt + "' onclick='OpenShowPage();'border=0 width='" + Wimg + "' height='" + Himg + "' style='CURSOR: hand' onmouseover=stopme('chinazads'); onmouseout=movechip('chinazads');>");
}

document.write(
"</div>");
chinazads();


function OpenShowPage()
{
                  
var nLeft=300;
                  
var nTop=300;
                  
var sFeatures='left='+nLeft+',top='+nTop+',height='+(window.screen.availHeight-850)+',width='+(window.screen.availWidth-700)+',help=no,status=no,toolbar=no,directories=no,resizable=yes,location=no,menubar=no,scrollbars=yes';
                  
var oWin=window.open("../AJZ20.Web/WaitTransactMatter/ShowSMasterClew.aspx",'',sFeatures);    
}

 

posted @ 2007-09-07 09:33  独孤求败  阅读(313)  评论(0编辑  收藏  举报