js实现网页右上角滑出会自动消失大幅广告的方法
本文实例讲述了js实现网页右上角滑出会自动消失大幅广告的方法。分享给大家供大家参考。具体实现方法如下:
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<title>js网页右上角滑出会自动消失的大幅广告效果</title>
<metahttp-equiv="content-type"content="text/html;charset=gb2312">
<!--把下面代码加到<head>与</head>之间-->
<scripttype="text/javascript"language="javascript">
vartime=500;
varw=0;
functionaddCount()
{
if(time>0)
{
time--;
w=w+5;
}
else
{
return;
}
if(w>278)//宽度
{
return;
}
document.getElementById("ads").style.display="";
document.getElementById("ads").style.width=w+"px";
setTimeout("addCount()",30);
}
window.onload=functionshowAds()
{
addCount();
setTimeout("noneAds()",3000);//停留时间
}
</script>
<scripttype="text/javascript"language="javascript">
varT=198;
varN=188;//高度
functionnoneAds()
{
if(T>0)
{
T--;
N=N-5;
}
else
{
return;
}
if(N<0)
{
document.getElementById("ads").style.display="none";
return;
}
document.getElementById("ads").style.width=N+"px";
setTimeout("noneAds()",30);
}
</script>
</head>
<body>
<!--把下面代码加到<body>与</body>之间-->
<divid="ads"style="margin:auto;display:none;position:absolute;width:200px;top:0px;right:0;height:200px;background-color:#d5282e;overflow:hidden;text-align:center;"><palign="center">欢迎访问<ahref="https://www.nhooo.com"target="_blank">毛票票</a>丨该特效收集于互联网,只为兴趣,不作商业用途。</p>
</div>
</body>
</html>
希望本文所述对大家的javascript程序设计有所帮助。