Dieser Artikel beschreibt die Methode von JS, um die Div -Schicht automatisch in 5 Sekunden zu blockieren. Teilen Sie es für Ihre Referenz. Die spezifische Implementierungsmethode lautet wie folgt:
Kopieren Sie den Code wie folgt: <html>
<kopf>
<titels> js implementiert die automatische Blockierung der Div -Schicht in 5 Sekunden </title>
<style type = "text/css">
<!-
#sponsoraddiv {Position: absolut; Höhe: 1; Breite: 1; Top: 0; links: 0;}
->
</style>
</head>
<body>
<Script Language = "JavaScript1.2">
adtime = 5; // die erwartete Zeit des Fensters
Chancead = 1;
var ns = (document.layers);
var ie = (document.all);
var w3 = (document.getElementById &&! IE);
AdCount = 0;
Funktion initad () {
if (! ns &&! dh &&! w3) return;
if (dh) addiv = eval ('document.all.sponsoraddiv.style');
sonst if (ns) addiv = eval ('document.layers ["sponsoraddiv"]');
sonst if (w3) addiv = eval ('document.getElementById ("sponsoraddiv"). style');
randad = math.ceil (math.random ()*hancead);
if (dh || w3)
Addiv.visibility = "sichtbar";
anders
addiv.visibility = "show";
if (randad == 1) showad ();
}
Funktion showad () {
if (adCount <adtime*10) {adCount+= 1;
if (dh) {documentWidth = document.body.Offsetwidth/2+document.body.scrollleft-20;
documentHeight = document.body.offseteight/2+document.body.scrolltop-20;}
sonst if (ns) {documentWidth = window.innnerwidth/2+window.pagexoffset-20;
documentHeight = window.innerHeight/2+window.pageyOffset-20;}
sonst if (w3) {documentWidth = self.innnerwidth/2+window.pagexoffset-20;
documentHeight = self.innerHeight/2+Fenster.pageyOffset-20;}
addiv.left = documentwidth-200; addiv.top = documentHeight-200;
setTimeout ("showAd ()", 100);} else Closead ();
}
Funktion Closead () {
if (dh || w3)
Addiv.Display = "Keine";
anders
Addiv.visibility = "Hide";
}
Onload = initad;
</script>
<div id = "sponsoraddiv" style = "Sichtbarkeit: versteckt">
<Tabelle bgcolor = "008000"> <tr> <td>
<Tabelle bgcolor = "f0fff0"> <tr> <td>
<Center> Willkommen bei www.csrcode.cn! <br> <br> Dieses Fenster wird automatisch in 5 Sekunden blockiert </center>
</td> </tr> </table> </td> </tr> </table> </div>
</body>
</html>
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.