Javascript里面分模式对话框和非模式对话框,其实两者区别就是在对话框被关闭之前用户能否在同一页面的其他地方进行工作。比如“打开文件”对话框便是典型的模式对话框,在你对这个对话框做出动作才能对打开该对话框的程序进行其他操作,而非模式对话框则不必。
模式对话框:showModalDialog
非模式对话框:showModelessDialog
vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])
返回值:vReturnValue,由对话框返回当然就是返回值了;
sURL:必选,为你要打开的页面;
vArguments:可选,用来向对话框传递参数;
sFeatures:可选,打开对话框的属性,各个属性直接用分号(;)隔开,包括以下一些参数,供参考:
1. dialogHeight: 对话框高度
2. dialogWidth: 对话框宽度
3. dialogLeft: 离屏幕左边的距离
4. dialogTop: 离屏幕上边的距离
5. center: { yes | no | 1 | 0 } : 口是否居中,默认yes,但仍可以指定高度和宽度
6. help: {yes | no | 1 | 0 }: 是否显示帮助按钮,默认yes
7. resizable: {yes | no | 1 | 0 } [IE5+]: 是否可被改变大小,默认no
8. status: {yes | no | 1 | 0 } [IE5+]: 是否显示状态栏。默认为yes[ Modeless]或no[Modal]
9. scroll: { yes | no | 1 | 0 | on | off }:指明对话框是否显示滚动条。默认为yes
10. dialogHide: { yes | no | 1 | 0 | on | off }:在打印或者打印预览时对话框是否隐藏。默认为no
11. edge: { sunken | raised }: 指明对话框的边框样式。默认为raised
12. unadorned: { yes | no | 1 | 0 | on | off }:默认为no

Code
1 <script language=javascript>
2 function openDialogWin()
3 {
4 var currentCode = document.all.code.value;
5 var result = window.showModalDialog("b.html",currentCode,"dialogHeight:260px; dialogWidth:400px; status:no; help:no; scroll:no");
6 if (result != 'cancel'){
7 document.all.code.value = result;
8 }
9 }
10 </script>
11 <input type="button" value="Edit Code" name="btn" onclick="openDialogWin()" />
12 <input type="text" value="C" name="code" id="code" readonly="readonly"/>

Code
<html>
<head>
<script language='javascript'>
var selectCode = window.dialogArguments;
alert(selectCode);
function putSelectCode(code){
selectCode = code;
ss();
}
function confirm(){
window.returnValue = selectCode;
window.close();
}
function cancel(){
window.returnValue = "cancel";
window.close();
}
</script>
</head>
<body>
<div align='center'>
<table border="1">
<thead>
<tr>
<th>code</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr onclick="putSelectCode('C')" ondblclick="putSelectCode('C');confirm();">
<td>C</td>
<td>CHILDREN VITAMINS</td>
</tr>
<tr onclick="putSelectCode('F')" ondblclick="putSelectCode('F');confirm();">
<td>F</td>
<td>FEMALE ONLY</td>
</tr>
<tr onclick="putSelectCode('I')" ondblclick="putSelectCode('I');confirm();">
<td>I</td>
<td>INCONTINENCE PRODUCTS</td>
</tr>
<tr onclick="putSelectCode('M')" ondblclick="putSelectCode('M');confirm();">
<td>M</td>
<td>MALE ONLY</td>
</tr>
<tr onclick="putSelectCode('P')" ondblclick="putSelectCode('P');confirm();">
<td>P</td>
<td>PRENATAL VITAMINS</td>
</tr>
</tbody>
</table>
<input type='button' value='Cancel' onclick='cancel()' /> <input type='button' value='Done' onclick='confirm()' />
</div>
<script language='javascript'>
function ss(){
var nodeList = document.getElementsByTagName("tr");
//alert(nodeList.length);
for (var i = 0; i < nodeList.length; i++){
//alert(nodeList[i].firstChild.nodeValue);
if (nodeList[i].firstChild.firstChild.nodeValue == selectCode){
//alert(nodeList[i].nodeName);
nodeList[i].style.background = "#ff0000";
}else{
nodeList[i].style.background = "#ffffff";
}
}
}
ss();
</script>
</body>
</html>