网页中移动的广告效果 鼠标悬停
//init cookie
function setCookie()
{
var FromUrl=window.location.toString();
FromUrl=FromUrl.replace("http://","");
FromUrl=FromUrl.replace("www.","");
FromUrl=FromUrl.substring(0,FromUrl.indexOf("/"));
var now=new Date();
//set cookie expires date 1000ms*60*60
now.setTime( now.getTime() + 1000 * 60 * 60 );
var the_cookie = "FromUrl="+FromUrl+";expires="+now.toGMTString()+";path=/";
document.cookie = the_cookie;//write Cookie
}
function readCookie()
{ var the_cookie = document.cookie;
return the_cookie;
}
setCookie();
//end of init cookie
var brOK=false;
var mie=false;
var vmin=2;
var vmax=5;
var vr=3;
var timer1;
var nowads;
var ad_width=0;
var ad_height=0;
// Domain Hosting email Domain Hosting email
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-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.vy=(vmax+vmin)*2-chip.vy;
if(chip.vy=pageX+pageW-chip.w)
{
chip.xx=pageX+pageW-chip.w;
chip.vx=-vmin-vmax*Math.random();
}
if(chip.xx>=pageW-ad_width)
{
chip.xx=chip.xx-20;
chip.vx=-vmin-vmax*Math.random();
}
if(chip.yy=pageY+pageH-ad_height)
{
chip.yy=pageY+pageH-ad_height;
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 nowads()
{
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();
}
nowads.named="nowads";
nowads.vx=vmin+vmax*Math.random();
nowads.vy=vmin+vmax*Math.random();
nowads.w=1;
nowads.h=1;
nowads.xx=0;
nowads.yy=0;
ad_width=nowads_img.width;
ad_height=nowads_img.height;
//alert(ad_height);
nowads.timer1=null;
movechip("nowads");
}
function getClientSize()
{
pageW=window.document.body.offsetWidth-8;
pageH=window.document.body.offsetHeight;
}
document.write('');
document.write('');
document.write('');
nowads();
window.onresize=getClientSize;
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]