纯粹是为了打发时间 , 手写了一个 js 的 alerta 控件。
代码如下
<html> <head> <script type = "text/javascript"> var alertobj = new Object (); var generalstyle = {zindex: 0, largura: "200px", altura: "100px", borda: "sólido espesso #ccccccc", fundo: "#ffffff", posição: "absoluto", top "35%", esquerda: "40%"} var txtyle = {textalign: "center"} var bn. TOP: "70%", cor: "#3333333", Fontweight: "Bold", OutlineColor: "#3366FF", Outlinestyle: "Ridge", OutlineWidth: "GENENSL", // ALLOB: txtstyle, btnset: btnstyle, isExist: false} alertobj.createComponent = function () {var component = document.createElement (argumentos [0]); var estilos = argumentos [1]; for (var propriedade var em estilos) {if (styles [propriedade]! = null) {try {component.style [propriedade] = styles [propriedade]; } catch (err) {document.write (err.name+":"+propriedade+"<br/>"); // Defina o erro da propriedade! }}} retornar componente; } alertobj.show = function () {if (! this.issexist) {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ão", 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); }} função mostra (s) {alertobj.show (s); } </script> </ad Head> <body> <p onclick = "show ('teste interno');"> clique em Mostrar alerta </p> </body> </html>