纯粹是为了打发时间、手写了一个js的アラート控件。
代码如下:
<html> <head> <script type = "text/javascript"> var alertobj = new object(); var generalStyle = {zindex:0、width: "200px"、height: "100px"、border: "fick solid #cccccc"、background: "#ffffff"、position: "absolute"、top: "35%"、left: "40%"} var txtstyle = {center "} var btnstyle =" "40:" "" 40%: "" 40 {"40%:" 40 "70%"、color: "#3333333"、fontweight: "bold"、outlinecolor: "#3366ff"、outlinestyle: "ridge"、outlinewidth: "thin"、// outline: "Thin Ridge#3366ff"、innerhtml: "ok" btnset:btnstyle、isexist:false} alertobj.createcomponent = function(){var component = document.createelment(arguments [0]); var styles = arguments [1]; for(スタイルのvarプロパティ){if(styles [property]!= null){try {component.style [property] = styles [property]; } catch(err){document.write(err.name+":"+property+"<br/>"); //プロパティエラーを設定します! }}} 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 = arguments [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); }} function show(s){alertobj.show(s); } </script> </head> <body> <p onclick = "show( 'inner test');"> show arert </p> </body> </html>をクリックします