仿windows關機對話方塊的提示框效果

來源:互聯網
上載者:User
提示:您可以先修改部分代碼再運行

<HTML><HEAD><TITLE> </tITLE></hEAD><BODY><form action="#"><input name=btn1 type=button value=有自訂按鈕 onclick=showalert1();><input name=btn2 type=button value=無自訂按鈕 onclick=showalert2();></form><script language="javascript"><!-- function gourl(e){ switch(e){ case 1: window.alert("點擊了確定按鈕."); break; case 2: break; case 3: window.alert("點擊了其它按鈕."); break; default: break; } } function showalert1(){ var Br = new innerMessageBox(); Br.ShowModal("帶第三個按鈕的樣本", "您確定要刪除該項嗎?", 320, 120, "gourl($)", "重試"); } function showalert2(){ var Br = new innerMessageBox(); Br.ShowModal("預設兩個按鈕的樣本", "您確定要刪除該項嗎?", 320, 120, "gourl($)"); }//--></script><script><!-- function innerMessageBox(){ var BackObject, FormObject; // 檢查頁面中是否存在該控制項. function checkIMBObject(){ if (document.getElementById("imb_Background")==null){ document.body.innerHTML += "<iframe id="imb_Background" src="about:blank" frameborder="0"></iframe>"; window.imb_Background.document.open(); window.imb_Background.document.write("<html><body bgcolor=red> sdfasdfasdf</body></html>"); window.imb_Background.document.close(); } if (document.getElementById("imb_FormModal")==null){ document.body.innerHTML += "<iframe id="imb_FormModal" src="about:blank" frameborder="0"></iframe>"; window.imb_FormModal.document.open(); window.imb_FormModal.document.write("<html><head><style><!--"); window.imb_FormModal.document.write("td{font-size:12px;"); window.imb_FormModal.document.write("//--></style></head><body scroll=no leftmargin=0 topmargin=0>"); window.imb_FormModal.document.write("<table width=100% height=100% bgcolor="#eeeeee"><tr><td align=left bgcolor=#3A80F3><div id="imb_Title" >"); window.imb_FormModal.document.write("</div></td></tr><tr><td align=left><div id="imb_Content" >"); window.imb_FormModal.document.write("</div></td></tr><tr><td id="imb_Body" align=center>"); window.imb_FormModal.document.write("</td></tr></table>"); window.imb_FormModal.document.write("</body></html>"); window.imb_FormModal.document.close(); } } // 顯示對話方塊控制項. this.ShowModal = function(iCaption, iMessage, iWidth, iHeight, iClickFunc, iOther){ var smWidth = 420, smHeight = 180, smCaption = "預設對話方塊", smMessage="您確定執行這項操作嗎?", smFunc, smObject, smAlpha, smInterval; if (arguments.length > 4 ){ smWidth = iWidth; smHeight = iHeight; smCaption = iCaption; smMessage = iMessage; smFunc = iClickFunc; } // 背景的漸顯. function checkIMBAlpha(){ smObject.style.filter = "alpha(opacity="+smAlpha+");"; smAlpha += 10; if (smAlpha>80){ clearInterval(smInterval); } } checkIMBObject(); this.BackObject = document.getElementById("imb_Background"); this.FormObject = document.getElementById("imb_FormModal"); smObject = this.BackObject; smAlpha = 0; this.BackObject.style.left = 0; this.BackObject.style.top = 0; this.BackObject.style.width = document.body.scrollWidth; this.BackObject.style.height = document.body.scrollHeight; this.BackObject.style.visibility = "visible"; smInterval = window.setInterval(checkIMBAlpha, 5); this.FormObject.style.left = document.body.clientWidth/2 - smWidth/2; this.FormObject.style.top = document.body.clientHeight/2 - smHeight/2; this.FormObject.style.width = smWidth; this.FormObject.style.height = smHeight; this.FormObject.style.visibility = "visible"; window.imb_FormModal.document.getElementById("imb_Title").innerHTML = "<b>" + smCaption + "</b>" + " -- 操作提示"; window.imb_FormModal.document.getElementById("imb_Content").innerHTML = smMessage; if (iOther==null || iOther==""){ window.imb_FormModal.document.getElementById("imb_Body").innerHTML = "<input type=hidden id=imb_Other name=imb_Other shortKey="O">   <input type=submit id=imb_Ok name=imb_Ok value="確定" shortKey="T">   <input type=button id=imb_Cancel name=imb_Cancel value="取消" shortKey="C">"; }else{ window.imb_FormModal.document.getElementById("imb_Body").innerHTML = "<input type=button id=imb_Other name=imb_Other value="+iOther+" shortKey="O">   <input type=submit id=imb_Ok name=imb_Ok value="確定" shortKey="T">   <input type=button id=imb_Cancel name=imb_Cancel value="取消" shortKey="C">"; } document.body.disabled = true; window.imb_FormModal.document.getElementById("imb_Ok").onclick= function(){ parent.document.body.disabled = false; if (smFunc!=null && smFunc!=""){ eval("parent." + smFunc.replace("$","1")); } parent.document.getElementById("imb_Background").style.visibility = "hidden"; parent.document.getElementById("imb_FormModal").style.visibility = "hidden"; } window.imb_FormModal.document.getElementById("imb_Cancel").onclick= function(){ if (smFunc!=null && smFunc!=""){ eval("parent." + smFunc.replace("$","2")); } parent.document.body.disabled = false; parent.document.getElementById("imb_Background").style.visibility = "hidden"; parent.document.getElementById("imb_FormModal").style.visibility = "hidden"; } window.imb_FormModal.document.getElementById("imb_Other").onclick= function(){ if (smFunc!=null && smFunc!=""){ eval("parent." + smFunc.replace("$","3")); } parent.document.body.disabled = false; parent.document.getElementById("imb_Background").style.visibility = "hidden"; parent.document.getElementById("imb_FormModal").style.visibility = "hidden"; } } }//--></script></bODY></hTML>
提示:您可以先修改部分代碼再運行
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.