test.htm
=====================================
<html>
<head>
<title> New Document </title>
<script language="javascript">
/*************************************************
功能:可以自己定製的confirm提示框,在IE6下測試通過
這個confirm用還可以做好多擴充,比如修改背景的顏色,修改那個顯示的圖片,修改按鈕的樣式,可以開啟象尋找那樣的非模態的視窗(需要IE5+),可以象定製網頁一樣隨便你修改
**************************************************/
/*
參數說明: strTitle confirm框的標題
strMessage confirm框要顯示的訊息
intType confirm框的選中的類型1為選中YES,2為選中NO
intWidth confirm框的寬度
intHeight confirm框的高度
*/
function myConfirm(strTitle,strMessage,intType,intWidth,intHeight)
{
var strDialogFeatures = "status=no;center=yes;help=no;dialogWidth="+intWidth+";dialogHeight="+intHeight+";scroll=yes;resize=no";
var args = new Array();
args[args.length] = strTitle;
args[args.length] = strMessage;
args[args.length] = intType;
var result = showModalDialog("myConfirm/myConfirm.htm",args,strDialogFeatures);
return result;
}
function test()
{
var myConfirmResult = myConfirm("這裡是標題","aaa",2,12,7)
if(myConfirmResult)
alert("您點了YES");
else if(myConfirmResult == false)
alert("您點了NO");
else
alert("您點了右上方的關閉");
}
</script>
</head>
<body>
<input type="button" value="點我試試" onclick="test()">
</html>
myConfirm/myConfirm.htm
=================================
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
<!--
var args = window.dialogArguments
try{
document.title = args[0]; //設定標題
}catch(e)
{
//這裡屏蔽了錯誤,防止萬一調用的傳遞參數不足
}
//-->
</script>
<title></title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
background-color: menu;
overflow: hidden;
overflow-x:hidden;
overflow-y:hidden;
}
-->
</style>
<script language="javascript">
function init()
{
var args = window.dialogArguments
try{
message.innerHTML = args[1]; //設定提示的資訊
if(args[2] == 1) //設定按鈕的選中狀態
ok.focus();
else
cancel.focus();
}catch(e)
{
//這裡屏蔽了錯誤,防止萬一調用的傳遞參數不足
}
ok.attachEvent("onclick",okClick); //設定YES按鈕的事件處理函數
cancel.attachEvent("onclick",cancelClick);//設定NO按鈕的事件處理函數
}
function okClick()//YES按鈕的事件處理函數
{
window.returnValue = true;
window.close();
}
function cancelClick()//NO按鈕的事件處理函數
{
window.returnValue = false
window.close();
}
window.attachEvent("onload",init)
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="5">
<tr>
<td><div align="center">
<img src="images/ico.gif" width="33" height="32"> </div></td>
<td><div align="left" id="message"></div></td>
</tr>
<tr>
<td>
<div align="right">
<input name="ok" type="button" id="ok" value=" 確定 ">
</div></td>
<td>
<div align="left">
<input name="cancel" type="button" id="cancel" value=" 取消 ">
</div></td>
</tr>
</table>
</body>
</html>
用到的一個圖片如下:
有點麻煩,如果你不介意用VBscript的話還是用VBscript簡單
msgbox("aaa?",257)