纯粹是为了打发时间 , 手写了一个 JS 的 ALERT 控件。
: :
<html> <head> <script type = "text/javaScript"> var alertobj = new Object () ؛ var GeneralStyle = {zindex: 0 ، العرض: "200px" ، الارتفاع: "100px" ، الحدود: "سميكة صلبة #CCCCCC" ، الخلفية: "#ffffff" ، الموضع: "absolute" ، top: "35 ٪" ، left: "40 ٪" "40 ٪" ، Top: "70 ٪" ، اللون: "#333333" ، الوزن ، "Bold" ، OutLinecolor: "#3366ff" ، outlinestyle: "Ridge" ، OutlineWidth: "Thin" ، // Outline: txtset: txtstyle ، btnset: btnstyle ، isexist: false} alertobj.createComponent = function () {var component = document.createlement (الوسيطات [0]) ؛ أنماط var = الوسائط [1] ؛ لـ (خاصية var في الأنماط) {if (الأنماط [property]! = null) {try {component.style [property] = styles [property] ؛ } catch (err) {document.write (err.name+":"+property+"<br/>") ؛ // set error property! }}} مكون الإرجاع ؛ } alertobj.show = function () {if (! 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 ("button" ، 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) ؛ }} دالة show (s) {alertobj.show (s) ؛ } </script> </head> <body> <p onClick = "show ('inner test') ؛"