纯粹是为了打发时间, 手写了一个 js 的แจ้งเตือน控件。
代码如下:
<html> <head> <script type = "text/javascript"> var alertobj = new Object (); var generalstyle = {zindex: 0, ความกว้าง: "200px", ความสูง: "100px", ชายแดน: "หนาของแข็ง #cccccc", พื้นหลัง: "#ffffff", ตำแหน่ง: "สัมบูรณ์", ด้านบน: "35%", ซ้าย: "40%" "70%", สี: "#333333", Fontweight: "Bold", Outlinecolor: "#3366FF", OutlineStyle: "Ridge", OutlineWidth: "Thin", // Outline: btnset: btnstyle, isExist: false} alertobj.createComponent = function () {var component = document.createElement (อาร์กิวเมนต์ [0]); var styles = อาร์กิวเมนต์ [1]; สำหรับ (คุณสมบัติ var ในสไตล์) {ถ้า (สไตล์ [คุณสมบัติ]! = null) {ลอง {component.style [คุณสมบัติ] = สไตล์ [คุณสมบัติ]; } catch (err) {document.write (err.name+":"+คุณสมบัติ+"<br/>"); // ตั้งค่าข้อผิดพลาดคุณสมบัติ! }}} ส่วนประกอบส่งคืน; } alertobj.show = function () {ถ้า (! this.isexist) {this.isexist = true; var bodyobj = document.body; bodyobj.style.zindex = -1; bodyobj.style.background = "#999999"; var divobj = this.createComponent ("div", this.generalset); var txtoBj = this.createComponent ("p", this.txtset); txtobj.innerhtml = อาร์กิวเมนต์ [0]; var btnobj = this.createComponent ("ปุ่ม", this.btnset); btnobj.innerhtml = this.btnset.innerhtml; btnobj.onclick = function () {bodyobj.style.zindex = 0; bodyobj.style.background = ""; Bodyobj.removeChild (divobj); if (alertobj.isexist) {alertobj.isexist = false; }} divobj.appendchild (txtoBj); divobj.appendchild (btnobj); BodyObj.AppendChild (divobj); }} ฟังก์ชั่นแสดง (s) {alertobj.show (s); } </script> </head> <body> <p onclick = "show ('การทดสอบภายใน');"> คลิกแสดงการแจ้งเตือน </p> </body> </html>