分析一下网页子窗口和网页父窗口的交互(2)

2008-02-23 08:03:53来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

{
var text = document.abc.text.value;
var win = window.open("","mywin", "menubar=no,width=400,height=100,resizeable=yes");
win.document.writeln(
"<title>输出结果</title>");
win.document.writeln(
"你的信息是:<p>");
win.document.writeln(text);
win.document.writeln(
"<input type=text name=child value=子窗口信息>");

//对子窗口本身操作,使用self对象,对父窗口操作使用opener对象,这是关键
//把子窗口中表单的值回传给父窗口,取代父窗口表单以前的值,然后关闭子窗口
win.document.writeln("<input type=button value=关闭自己 onClick='window.opener.abc.text.value=self.child.value;self.close()'>");
//可以控制关闭父窗口
win.document.writeln("<input type=button value=关闭父窗口 onClick='window.opener.opener=null;window.opener.close()'>");
//刷新父窗口
win.document.writeln("<input type=button value=刷新父窗口 onClick='window.opener.location.reload()'>");

win.document.close();
win.focus();
}

</script> <form name=abc method=post>
<input type=text name=text size=50>
<input type=button value=提交 onClick="outPut()">
</form>

3、不是同页面的子窗口和父窗口交互

假设我们涉及到外部程序,比如php、asp等等,那么我们处理的可能是两个页面,比如,上传功能,我们就是需要打开一个新页面,然后再把新页面中的值传递给父页面。
局部代码实例:

<input type="input" value="" name

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:弹出窗口window.open()的参数列表

下一篇:FireFox 如何用Javascript 修改状态栏