JS實現5秒鐘自動關閉的div廣告層

來源:互聯網
上載者:User

標籤:

<html>    <head>    <title>JS實現5秒鐘自動關閉的div廣告層丨禮堂座椅丨輕質隔牆板</title>    <style type="text/css">    <!--    #sponsorAdDiv {position:absolute; height:1; width:1; top:0; left:0;}    -->    </style>    </head>    <body>    <SCRIPT LANGUAGE="JavaScript1.2">    adTime=5;  //關閉視窗等待的時間    chanceAd=1;    var ns=(document.layers);    var ie=(document.all);    var w3=(document.getElementById && !ie);    adCount=0;    function initAd(){    if(!ns && !ie && !w3) return;    if(ie)                adDiv=eval(‘document.all.sponsorAdDiv.style‘);    else if(ns)        adDiv=eval(‘document.layers["sponsorAdDiv"]‘);    else if(w3)        adDiv=eval(‘document.getElementById("sponsorAdDiv").style‘);    randAd=Math.ceil(Math.random()*chanceAd);    if (ie||w3)    adDiv.visibility="visible";    else    adDiv.visibility ="show";    if(randAd==1) showAd();    }    function showAd(){    if(adCount<adTime*10){adCount+=1;    if (ie){documentWidth  =document.body.offsetWidth/2+document.body.scrollLeft-20;    documentHeight =document.body.offsetHeight/2+document.body.scrollTop-20;}    else if (ns){documentWidth=window.innerWidth/2+window.pageXOffset-20;    documentHeight=window.innerHeight/2+window.pageYOffset-20;}    else if (w3){documentWidth=self.innerWidth/2+window.pageXOffset-20;    documentHeight=self.innerHeight/2+window.pageYOffset-20;}    adDiv.left=documentWidth-200;adDiv.top =documentHeight-200;    setTimeout("showAd()",100);}else closeAd();    }    function closeAd(){    if (ie||w3)    adDiv.display="none";    else    adDiv.visibility ="hide";    }    onload=initAd;    </script>    <div id="sponsorAdDiv" style="visibility:hidden">    <table width="450" height="350" bgcolor="008000"><tr><td>    <table width="445" height="345" bgcolor="F0FFF0"><tr><td>    <center>welcome to www.CsrCode.cn!<BR><BR>這個視窗將在5秒後自動關閉</center>    </td></tr></table></td></tr></table></div>    </body>    </html>    <br><br><hr>

 

JS實現5秒鐘自動關閉的div廣告層

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.