纯粹是为了打发时间,手写了一个js的警报控件。
代码如下:
<html> <head> <script type =“ text/javaScript”> var alertobj = new Object(); VAR GeneralStyle = {Zindex:0,宽度:“ 200px”,高度:“ 100px”,边界:“厚实的#cccccc”,背景:“ #ffffff”,位置:“绝对”,top:“ 35%”,左:“ 40%”} var txtStyle = var txtStyle = verv {textAlign:peration's peration's perition's perition's perition's perition:peration's perition:peration's perition:peration's peration。 “ 70%”,颜色:“#333333”,fontweight:“ Bold”,OutlineColor:“#3366ff”,Outlinestyle:“ Ridge”,OutlineWidth,OutlineWidth:“ thin”,// outline:“ thin ridge#3366ff”,ninthhtml:ok oignhtml:“ ok oil oferobj = pertareals = nersals:nersal nertals:nersal nestle nertal nertless:nersal nertals nestlets: btnset:btnstyle,isexist:false} alertobj.createComponent = function(){var component = document.createelement(greatelement(gragonments [0]); var styles =参数[1]; for(styles中的var属性){if(styles [property]!= null){try {component.style [property] = styles [property]; } catch(err){document.write(err.name+“:”+property+“ <br/>”); //设置属性错误! }}}返回组件; } 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 = gragonments [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(arperobj.isexist){alertobj.isexist = false; }} divobj.appendchild(txtObj); DivoBj.AppendChild(BTNOBJ); Bodyobj.AppendChild(DivoBJ); }}函数show(s){alertobj.show(s); } </script> </head> <body> <p onclick =“ show('内部测试');”>单击“ show nerver </p> </hody> </hody> </html>”