加入收藏 | 设为首页 | 会员中心 | 我要投稿 核心网 (https://www.hxwgxz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营 > 正文

showModalDialog基本操作:父子窗口互传参数

发布时间:2018-09-03 16:05:48 所属栏目:运营 来源:站长网
导读:ShowModalDialog基本操作:父子窗口互传参数 父窗口代码: Copy to Clipboard 引用的内容:[www.veryhuo.com]!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd html xmlns=http://w

ShowModalDialog基本操作:父子窗口互传参数

父窗口代码:

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>父窗口</title>
</head>
<body>
<script type="text/javascript">
function onOpenWindow(){
//showModalDialog的第二个参数是传递给子窗口的值
//在子窗口可以通过window.dialogArguments方法获取
//如果不需要传递,这个参数就用window本身
var obj = document.getElementById("rtnValue").value;
var result = window.showModalDialog("window.htm",obj,"dialogWidth:500px;dialogHeight:400px");
if(result != null){
var name = result[0];
document.getElementById("rtnValue").value = name;
}}
</script>
<input name="rtnValue" type="text" id="rtnValue" value="" />
<input type="submit" name="Submit" value="打开子窗口" onclick='onOpenWindow()' />
</body>
</html>

子窗口代码:

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>子窗口</title>
</head>
<body>
请输入要返回的值: <input name="txtName" type="text" id="txtName" />
<input type="submit" name="Submit" value="确定" onclick='onOK();' />
<script type="text/javascript">
document.getElementById("txtName").value = window.dialogArguments;function onOK(){
var runValue=new Array;
runValue[0]=document.getElementById("txtName").value;
window.returnValue = runValue; window.close();}
</script>
</body>
</html>

文章来自:http://www.cnblogs.com/huanghai/

(编辑:核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读