Dieser Artikel beschreibt die einfache Implementierung von schwimmenden Fenstereffekten durch JS. Teilen Sie es für Ihre Referenz wie folgt weiter:
HTML -Teil:
<! DocType html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transsitional.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"/> <title> unauftitelte Dokument </title> <style type = "text/cs Padding: 0;} a img {Border: 0;} </style> </head> <body> <div style = "Höhe: 2000px; Hintergrund: #ccc; Anzeige: Keine;"> </div> <!-div id = "floatad" style = "Position: Fix; Position: absolut; _top: Ausdruck (Dokument.DocumentElement.Scrolltop+Dokument. No-Repeat; style = "width: 26px; Höhe: 26px; float: rechts;"> </div> <div onclick = "open_online ();"> </div> </div> <div id = "floatside" style = "width: 141px; Höhe: 579px; Position: Fixe! Wichtig; Position: absolut; _top: Ausdruck (Dokument.DocumentElement.Scrolltop+Dokument.DocumentElement.clientHeight-This.Offseththeight); onclick = "open_online ();> </div-> </body> </html> <script type =" text/javaScript "src =" online.js "> </script>JS Teil:
// JavaScript -Dokument // Floating Advertising Image var floatadimg = "Images/Onlinesay.jpg"; // Floating Sidebar Image var floatsimg = "Images/OnLinetel.gif"; // Online -Kommunikationsfunktion Open_online () {{ window.open ('http://p.qiao.baidu.com//im/index?sitesp. _top: Ausdruck (Dokument.DocumentElement.Scrolltop+Dokument. Breite: 487px; Höhe: 320px; _top: Ausdruck (Dokument.DocumentElement.Scrolltop+Dokument floating advertising function closeFAd(){ document.getElementById('floatAd').style.display = 'none';}//Open floating ad function showFAd(){ document.getElementById('floatAd').style.display = 'block';}//Open floating window function showFloat(){ document.getElementById('floatAd').style.display = 'block';} // Öffnen Sie die Fensterfunktion Showfloat () {document.getElementById ('floatad'). style.display = 'block';} // Öffnen Sie das Fenster für 20 Sekunden und führen Sie SetTimeout nur einmal aus (Showfad, 20000); // öffnen setInterval (showfloat, 30000);Die Renderings sind wie folgt:
For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript Traversal Algorithm and Skills", "Summary of JavaScript Switching Special Effects and Skills", "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Animation Special Effects and Skills", "Summary of JavaScript Errors and Debugging Skills", "Summary of JavaScript Data Strukturen und Algorithmusfähigkeiten "und" Zusammenfassung der Verwendung von JavaScript Mathematical Operation ""
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.