纯粹是为了打发时间 , 手写了一个 JS 的 Alerte 控件。
:
<html> <éad- head> <script type = "text / javascript"> var alertoBj = new object (); var GeneralStyle = {Zindex: 0, largeur: "200px", hauteur: "100px", bordure: "Solide épais #ccccc", arrière-plan: "#ffffff", position: "Absolu", en haut: "35%", gauche: "40%"} var txtstyle = {Textalign: "Centre"} var btnstyle = {position: "Absolu", "gauche"}, topnstyle = {position: "Absolu" " "70%", Couleur: "# 333333", Fontweight: "Bold", outlineColor: "# 3366ff", Outlinestyle: "Ridge", OutlineWidth: "Thin", // Outline: "Thin Ridge # 3366FF", innerhtml: "OK"} ALERTOBJ = {GeneralSet: GeneralStyle, TXTSTE btnset: btnstyle, isExist: false} alertoBj.createComponent = function () {var composant = document.CreateElement (arguments [0]); var styles = arguments [1]; pour (var propriété dans les styles) {if (styles [propriété]! = null) {try {composant.style [propriété] = styles [propriété]; } catch (err) {document.write (err.name + ":" + propriété + "<br/>"); // Définir l'erreur de propriété! }}} 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 ("bouton", 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.ApendChild (btnobj); Bodyobj.ApendChild (Divobj); }} fonction show (s) {alertObj.show (s); } </ script> </ head> <body> <p onClick = "show ('Inner Test');"> Cliquez sur Show Alert </p> </ body> </html>