Ygs

Feed Rss

JS 窗口间通信摘要

07.02.2010, 分类不能, by , 1次阅读.

1.打开一个新窗口:window.open();为了便于父窗口操作子窗口可以为window.open()定义一个变量,例如:

var opW = window.open(‘tests.html’,'popup’,'width=300,height=300′);

这样要关闭子窗口可直接使用:opW.close();
要操作子窗口元素,例如:

opW.document.getElementById(“fartherWindowTxt”).innerHTML = “操作子窗口”;

2.子窗口可以使用window.opener来引用父窗口:

window.opener.document.getElementById(“fartherWindowTxt”).innerHTML=”子窗口操作父窗口!”;

3.窗口关闭自身窗口可以使用:window.close();

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>