纯粹是为了打发时间 , 手写了一个 JS 的 Alerta 控件。
代码如下 :
<html> <head> <script type = "text/javaScript"> var alertaBJ = new Object (); var generalstyle = {zindex: 0, ancho: "200px", altura: "100px", borde: "grueso sólido #cccccc", fondo: "#ffffff", posición: "absoluto", top: "35%", izquierda: "40%"} var txtStyle = {textalign: "center"} var btnstyle = {posición: "absoluto", "40%", 40%", izquierda:", ",", ",", ",", ",", "," "70%", color: "#333333", fontWeight: "bold", outlineColor:"#3366FF", outlineStyle:"ridge", outlineWidth:"thin", //outline: "thin ridge #3366FF", innerHTML: "OK" } alertObj = { generalSet: generalStyle, txtSet: txtStyle, btnSet: btnstyle, isExist: false} alertobj.createComponent = function () {var component = document.createElement (argumentos [0]); estilos var = argumentos [1]; for (propiedad var en estilos) {if (styles [propiedad]! = null) {try {component.style [propiedad] = styles [propiedad]; } catch (err) {document.write (err.name+":"+propiedad+"<br/>"); // Establezca error de propiedad! }}} componente de retorno; } alertobj.show = function () {if (! this.isexist) {this.isexist = true; var bodyObj = document.body; Bodyobj.style.zindex = -1; Bodyobj.style.background = "#9999999"; var divobj = this.createComponent ("div", this.generalSet); var txtobj = this.createComponent ("P", this.txtset); txtobj.innerhtml = argumentos [0]; var btnobj = this.createComponent ("botón", 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); }} función show (s) {alertobj.show (s); } </script> </head> <body> <p onClick = "show ('interner test');"> haga clic en Mostrar alerta </p> </body> </html>