您的位置:首页 > Web前端 > JavaScript

js实现对话框与父窗体的传值

2006-07-28 10:50 225 查看
主窗口 main.html

<html>
<head>
<script language="javascript">
function abc()
{
window.showModalDialog("newwindow.html",window,"dialogWidth:500px;dialogHeight:420px;help:0;status:0;resizable:0;scroll:0;center:1;");
}
</script>

</head>
<body>
<img onclick=abc()>
<INPUT type="text" name="me">

</body>
</html>

对话框 newwindow.html

<html>
<head>
<script language="javascript">
var oParent;
function addvalue()
{
oParent = window.dialogArguments;
alert(document.all["a"].value);
oParent.document.all["me"].value=document.all["a"].value;
window.close();
}
</script>

</head>
<body>
<INPUT type="text" name="a" value="hello~">
<INPUT style="WIDTH: 80px" onclick="addvalue();" type="button" value="给父窗体赋值">
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: