In diesem Artikel wird die Methode zur Implementierung eines Div-Popup-Fensters mit einer Schließschaltfläche in JS+CSS beschrieben. Teilen Sie es für Ihre Referenz. Die spezifische Implementierungsmethode lautet wie folgt:
Kopieren Sie den Code wie folgt: <html>
<kopf>
<titels> JS+CSS implementiert das Div -Popup -Fenster mit Schließschaltfläche </title>
<Script>
Funktion sperren () {
document.all.ly.style.display = "block";
document.all.ly.style.width = document.body.clientwidth;
document.all.ly.style.height = document.body.clientHeight;
document.all.layer2.style.display = 'block';
}
Funktion lock_checkform (theform) {
document.all.ly.style.display = 'none'; document.all.layer2.style.display = 'none';
false zurückgeben;
}
</script>
<style type = "text/css">
<!-
.Style1 {Schriftgröße: 12px}
A: Link {
Farbe: #ffffff;
Textdekoration: Keine;
}
A: besucht {
Textdekoration: Keine;
}
A: Hover {
Textdekoration: Keine;
}
A: aktiv {
Textdekoration: Keine;
}
->
</style>
<meta http-äquiv = "content-type" content = "text/html; charset = gb2312">
</head>
<body>
<P Align = "Center">
<input type = "button" value = "popup div" onclick = "sperrung ()" />
</p>
<div id = "ly" style = "Position: absolut; top: 0px; filter: alpha (opacity = 60); Hintergrundfarbe: #777;
Z-Index: 2; links: 0px; Anzeige: keine; ">
</div>
<!-Floating Framework Start->
<div id = "layer2" align = "center" style = "Position: absolut; Z-Index: 3; links: Ausdruck ((document.body.Offsetwidth-540)/2); obere: Ausdruck ((Dokument.Body.Offsetheighthight-170)/10);
Hintergrundfarbe: #fff; Anzeige: keine; ">
<Table CellPadding = "0" cellpacing = "0" style = "border: 0 solide #e7e3e7;
Grenzkollapse: Zusammenbruch; ">
<tr>
<td style = "Hintergrundfarbe: #73A2D6; Farbe: #ffff; Padding-Links: 4px; Padding-Top: 2px;
Schriftgewicht: fett; Schriftgröße: 12px; "Valign =" Middle ">
<div align = "rechts"> <a href = javaScript:; onclick = "lock_checkform (this);"> [schließen] </a> </div> </td>
</tr>
<tr>
<td align = "center">
</td>
</tr>
</table>
</div>
<!-schwimmendes Rahmen Ende->
</body>
</html>
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.