Javascript:如何引用通过发布打开的子窗口
我想引用我打开的子窗口,以便我可以从父窗口调用它的一些方法。为此,我需要保留对窗口的引用。我找到的所有示例都保留引用:
var windowRef = window.open(...);
但我不使用 window.open。我提交表单是因为我需要向其中发布数据:
var frmMain = document.forms['frmMain'];
frmMain.action = "http://www.somedomain.com";
link.attr("href");
frmMain.target = "_blank";
frmMain.submit();
如何使用帖子引用打开的窗口?谢谢!
I want to reference the child window that I have opened so that I can call some method on it from the parent. To do that I need to keep a reference to the window. All the examples I have found keep the reference by:
var windowRef = window.open(...);
But I don't use window.open. I submit the form because I need to post data to it:
var frmMain = document.forms['frmMain'];
frmMain.action = "http://www.somedomain.com";
link.attr("href");
frmMain.target = "_blank";
frmMain.submit();
How can I reference the open window using a post? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只要您的
target
属性设置为真实名称,窗口对象的open
方法实际上可以为您创建引用。编辑:这是一个演示 jsfiddle。
The
open
method of the window object can actually create the reference for you as long as yourtarget
attribute is set to a real name.edit: Here is a demonstration jsfiddle.