仿windows关机对话框的提示框效果

  1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2<HTML>
  3<HEAD>
  4<TITLE> 仿windows关机对话框的提示框效果 </TITLE>
  5</HEAD>
  6
  7<BODY>
  8<form action="#">
  9<input name=btn1 type=button value=有自定义按钮 onclick=showalert1();>
 10<input name=btn2 type=button value=无自定义按钮 onclick=showalert2();>
 11
 12</form>
 13<script language="javascript">
 14<!--
 15    function gourl(e){
 16        switch(e){
 17            case 1:
 18                window.alert("点击了确定按钮.");
 19                break;
 20            case 2:
 21                break;
 22            case 3:
 23                window.alert("点击了其它按钮.");
 24                break;
 25            default:
 26                break;
 27        }

 28    }

 29
 30    function showalert1(){
 31        var Br = new innerMessageBox();
 32        Br.ShowModal("带第三个按钮的示例""您确定要删除该项吗?"320120"gourl($)""重试");
 33    }

 34
 35    function showalert2(){
 36        var Br = new innerMessageBox();
 37        Br.ShowModal("默认两个按钮的示例""您确定要删除该项吗?"320120"gourl($)");
 38    }

 39//-->
 40
</script>
 41<script>
 42<!--
 43    function innerMessageBox(){
 44        var BackObject, FormObject;
 45
 46        //    检查页面中是否存在该控件.
 47        function checkIMBObject(){
 48            if (document.getElementById("imb_Background")==null){
 49                document.body.innerHTML += "<iframe id=\"imb_Background\" src=\"about:blank\" style=\"position:absolute;left:0;top:0;0px;height:0px;visibility:hidden;\" frameborder=\"0\"></iframe>";
 50                window.imb_Background.document.open();
 51                window.imb_Background.document.write("<html><body bgcolor=red>&nbsp;sdfasdfasdf</body></html>");
 52                window.imb_Background.document.close();
 53            }

 54            if (document.getElementById("imb_FormModal")==null){
 55                document.body.innerHTML += "<iframe id=\"imb_FormModal\" src=\"about:blank\" style=\"position:absolute;left:0;top:0;0px;height:0px;visibility:hidden;border-bottom:2px solid #999999;border-right:2px solid #999999;border-top:1px solid #F8F6C1;border-left:1px solid #F8F6C1;\" frameborder=\"0\"></iframe>";
 56                window.imb_FormModal.document.open();
 57                window.imb_FormModal.document.write("<html><head><style><!--");
 58                window.imb_FormModal.document.write("td{font-size:12px;");
 59                window.imb_FormModal.document.write("//--></style></head><body scroll=no leftmargin=0 topmargin=0>");
 60                window.imb_FormModal.document.write("<table width=100% height=100% bgcolor=\"#eeeeee\"><tr><td  align=left bgcolor=#3A80F3><div id=\"imb_Title\" style=\"padding-left:3px;padding-right:3px;color:white;font-family:verdana;\">");
 61                window.imb_FormModal.document.write("</div></td></tr><tr><td align=left><div id=\"imb_Content\" style=\"padding:7px;\">");
 62                window.imb_FormModal.document.write("</div></td></tr><tr><td id=\"imb_Body\" align=center>");
 63                window.imb_FormModal.document.write("</td></tr></table>");
 64                window.imb_FormModal.document.write("</body></html>");
 65                window.imb_FormModal.document.close();
 66            }

 67        }

 68
 69        //    显示对话框控件.
 70        this.ShowModal = function(iCaption, iMessage, iWidth, iHeight, iClickFunc, iOther){
 71            var smWidth = 420, smHeight = 180, smCaption = "默认对话框", smMessage="您确定执行这项操作吗?", smFunc, smObject, smAlpha, smInterval;
 72            if (arguments.length > 4 ){
 73                smWidth = iWidth;
 74                smHeight = iHeight;
 75                smCaption = iCaption;
 76                smMessage = iMessage;
 77                smFunc = iClickFunc;
 78            }

 79            //    背景的渐显.
 80            function checkIMBAlpha(){
 81                smObject.style.filter = "alpha(opacity="+smAlpha+");";
 82                smAlpha += 10;
 83                if (smAlpha>80){
 84                    clearInterval(smInterval);
 85                }

 86            }

 87            checkIMBObject();
 88            this.BackObject = document.getElementById("imb_Background");
 89            this.FormObject = document.getElementById("imb_FormModal");
 90            smObject = this.BackObject;
 91            smAlpha = 0;
 92            this.BackObject.style.left = 0;
 93            this.BackObject.style.top = 0;
 94            this.BackObject.style.width = document.body.scrollWidth;
 95            this.BackObject.style.height = document.body.scrollHeight;
 96            this.BackObject.style.visibility = "visible";
 97            smInterval = window.setInterval(checkIMBAlpha, 5);
 98
 99            this.FormObject.style.left = document.body.clientWidth/2 - smWidth/2;
100            this.FormObject.style.top = document.body.clientHeight/2 - smHeight/2;
101            this.FormObject.style.width = smWidth;
102            this.FormObject.style.height = smHeight;
103            this.FormObject.style.visibility = "visible";
104            window.imb_FormModal.document.getElementById("imb_Title").innerHTML = "<b>" + smCaption + "</b>" + " -- 操作提示";
105            window.imb_FormModal.document.getElementById("imb_Content").innerHTML = smMessage;
106            if (iOther==null || iOther==""){
107                window.imb_FormModal.document.getElementById("imb_Body").innerHTML = "<input type=hidden id=imb_Other name=imb_Other shortKey=\"O\"> &nbsp; <input type=submit id=imb_Ok name=imb_Ok value=\"确定\" shortKey=\"T\"> &nbsp; <input type=button id=imb_Cancel name=imb_Cancel value=\"取消\" shortKey=\"C\">";
108            }
else{
109                window.imb_FormModal.document.getElementById("imb_Body").innerHTML = "<input type=button id=imb_Other name=imb_Other value="+iOther+" shortKey=\"O\"> &nbsp; <input type=submit id=imb_Ok name=imb_Ok value=\"确定\" shortKey=\"T\"> &nbsp; <input type=button id=imb_Cancel name=imb_Cancel value=\"取消\" shortKey=\"C\">";
110            }

111            document.body.disabled = true;
112            window.imb_FormModal.document.getElementById("imb_Ok").onclick= function(){
113                parent.document.body.disabled = false;
114                if (smFunc!=null && smFunc!=""){
115                    eval("parent." + smFunc.replace("$","1"));
116                }

117                parent.document.getElementById("imb_Background").style.visibility = "hidden";
118                parent.document.getElementById("imb_FormModal").style.visibility = "hidden";
119            }

120            window.imb_FormModal.document.getElementById("imb_Cancel").onclick= function(){
121                if (smFunc!=null && smFunc!=""){
122                    eval("parent." + smFunc.replace("$","2"));
123                }

124                parent.document.body.disabled = false;
125                parent.document.getElementById("imb_Background").style.visibility = "hidden";
126                parent.document.getElementById("imb_FormModal").style.visibility = "hidden";
127            }

128            window.imb_FormModal.document.getElementById("imb_Other").onclick= function(){
129                if (smFunc!=null && smFunc!=""){
130                    eval("parent." + smFunc.replace("$","3"));
131                }

132                parent.document.body.disabled = false;
133                parent.document.getElementById("imb_Background").style.visibility = "hidden";
134                parent.document.getElementById("imb_FormModal").style.visibility = "hidden";
135            }

136        }

137    }

138//-->
139
</script>
140</BODY>
141</HTML>
142
原文地址:https://www.cnblogs.com/RuiLei/p/491206.html