纯粹是为了打发时间 , 手写了一个 JS 的 Peringatan 控件。
代码如下 :
<html> <adept> <script type = "text/javaScript"> var alertoBj = objek baru (); var generalStyle = { zIndex: 0, width: "200px", height: "100px", border: "thick solid #CCCCCC", background: "#FFFFFF", position: "absolute", top: "35%", left: "40%" } var txtStyle = { textAlign: "center" } var btnStyle = { position: "absolute", left: "40%", top: "70%", Color: "#3333333", kelas font: "Bold", Outlinecolor: "#3366ff", Outlinestyle: "Ridge", Outlinewidth: "Tipis", // Garis Besar: Tips: Tips: Generets, Generets, InnerHTML: "OK"}}} {{} {{} {{} {{}} {{}} {} {} {} {} {} {}} THEP: THE RIMP: THE RIMP: THEP: "OK," OK, "OK" OK "OK" OK "OK" OK "OK" OK "OK" OK "} btnset: btnstyle, isExist: false} alertoBj.createComponent = function () {var component = document.createElement (argumen [0]); var styles = argumen [1]; untuk (properti var dalam gaya) {if (styles [properti]! = null) {coba {component.style [properti] = styles [properti]; } catch (err) {document.write (err.name+":"+properti+"<br/>"); // atur kesalahan properti! }}} return component; } 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 = argumen [0]; var btnobj = this.createComponent ("tombol", 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); }} function show (s) {alertoBj.show (s); } </script> </head> <body> <p onclick = "show ('test dalam');"> klik tunjukkan peringatan </p> </body> </html>