分享

JS大幅卷屏广告代码

 weiledream 2011-07-12
JS大幅卷屏广告代码,广告从下到上依次卷起来,逐渐显示出网页内容,各大门户网站都有使用,效果不错,代码拷贝后请另存一个文件 ,使用时候调用,这样更合理。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE>JS大幅卷屏广告代码</TITLE>
 </HEAD>
<BODY>
<script language="javascript">
function $(ele){return document.getElementById(ele)}
var popIMG={
stimer:null,
etimer:null,
init:function(imgurl,width,height){this.imgurl=imgurl;this.width=width;this.height=height;},
createE:function(){
var obj=document.createElement("div");
obj.id="imgid";
obj.style.width=popIMG.width+"px";
obj.style.height=popIMG.height+"px";
//obj.style.backgroundColor="red";
obj.style.top=0+"px";
obj.style.left=Math.ceil((document.body.clientWidth-popIMG.width)/2)+"px";
obj.style.position="absolute";
obj.style.zIndex=100;
obj.style.overflow="hidden"
var img=document.createElement("img");
img.style.width=popIMG.width+"px";
img.style.height=popIMG.height+"px";
img.src=popIMG.imgurl;
obj.appendChild(img);
document.body.appendChild(obj);
},
start:function(){
popIMG.createE();
popIMG.stimer=setTimeout("popIMG.fade()",3000);
},
fade:function(){
if(popIMG.stimer)clearTimeout(popIMG.stimer);
$("imgid").style.height=(parseInt($("imgid").style.height)-5)+"px";
popIMG.etimer=setTimeout("popIMG.fade()",10);
if(parseInt($("imgid").style.height)<=0){clearTimeout(popIMG.etimer);$("imgid").innerHTML="";document.body.removeChild($("imgid"));}
}
}
popIMG.init("/jscss/demoimg/site.gif",1021,675);
window.onload=popIMG.start;
</script>
</BODY>
</HTML>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约