一个showModalDialog实现值传递的例子
共三个页面:main.htm,sub.htm和pop.htm
main里面的iframe链接到sub.htm
main上的button弹出pop.htm
在pop.htm上输入数据点击“确认”后,将输入的数据显示到sub.htm中的文本框上
main.htm:
<HTML>
<HEAD>
<title>main</title>
<script id=clientEventHandlersJS language=javascript>
<!--
function buttonOK_onclick() {
var popResult = window.showModalDialog("pop.htm");
window.frames["SubForm"].Form1.txtSub.value = popResult;
window.frames["SubForm"].Form1.txtSub.disabled = false;
}
//-->
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<INPUT type="button" value="OK" id="buttonOK" name="buttonOK" onclick="return buttonOK_onclick()"/>
<iframe id="SubForm" src="sub.htm"></iframe>
</form>
</body>
</HTML>sub.htm:
<html>
<head>
<title>sub</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<INPUT id="txtSub" name="txtSub" disabled type="text" value="默认值">
</form>
</body>
</html>pop.htm:
<HTML>
<HEAD>
<title>pop</title>
<script id=clientEventHandlersJS language=javascript>
<!--
function buttonOK_onclick() {
window.returnValue = Form1.txtValue.value;
window.close();
}
//-->
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<INPUT id="txtValue" type="text" name="txtValue">
<INPUT id="buttonOK" type="button" value="确认" name="buttonOK" onclick="return buttonOK_onclick()">
</form>
</body>
</HTML>本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利
This posting is provided "AS IS" with no warranties, and confers no rights.
This posting is provided "AS IS" with no warranties, and confers no rights.


浙公网安备 33010602011771号