模态窗口的运用

本文介绍了如何使用HTML、CSS和JavaScript在网页中创建并调用模态对话框,包括主窗体触发弹出窗体的方法、弹出窗体接收并返回参数的过程。

1   在主窗体

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript">
function testModalDialog()
{
var p = new Object();
p.name = "chengdong";
var res = window.showModalDialog("2.html", p);
alert("返回值" + res);

}

</script>
</head>
<body>
<a href="javascript:testModalDialog()">弹出模态窗口</a>
</body>
</html>

 

 

 

2  弹出的窗体

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>我是模态窗体</title>
<script type="text/javascript">

var obj = window.dialogArguments;
alert("你传递的参数是"+obj.name);
function closeWin()
{
window.returnValue = document.getElementById("txtName").value;
window.close();
}
</script>
</head>
<body>
模态窗体赶回值给父窗体
<input type="text" id="txtName"/>
<input type="button" value="关闭" onclick="closeWin()" />
</body>
</html>

转载于:https://www.cnblogs.com/cdaq/p/3921574.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值