在网页中使用对话框

博客介绍了在HTML中创建桌面式对话框的代码。通过window.open函数可打开模态或非模态窗口,其中modal=1为模态,modal=0为非模态,但IE6不支持此参数。还提到在IE中可用window.showModalDialog显示模态对话框,不过只有IE支持该方式,Mozilla等浏览器不支持。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<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等都不支持。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值