<html>
<head>
<script>
function openDialog()
{
var left = screen.width/2 - 340/2;
var top = screen.height/2 - 350/2;
window.open('dialog.html','dialog','modal=1,left=' + left + ',top=' + top + ',height=350,width=330,resizable=0,status=0,scrollbars=0');
}
script>
head>
<body style="margin: 20px">
<div style="font-family: arial;font-size:12px;">Create desktop like dialogs:
div>
<br>
<input type="button" value="Open Dialog Window" onclick="openDialog()">
body>
html>
注意window.open参数中的modal=1,这个是打开新窗口为模态的,如果modal=0那么就是非模态的。
在IE6中不支持此参数,不管你怎么设置,它总是非模态的。
在Mozilla Firefox中测试OK。
另外在IE中我们可以使用:window.showModalDialog('dialog.html',
window,'status:no;dialogWidth:460px;dialogHeight:400px');来显示一个模态的对话框。
同样这种方式也只有IE自己支持,其他的浏览器比如Mozilla,Netscaper等都不支持。