window.opener 实际上就是通过window.open打开的窗体的父窗体。
比如在父窗体parentForm里面 通过 window.open("subForm.html"),那么在subform.html中 window.opener就代表parentForm,可以通过这种方式设置父窗体的值或者调用js方法。
如:1,window.opener.test(); ---调用父窗体中的test()方法
Window postMessage() 方法
postMessage() 方法用于安全地实现跨源通信。
window.opener.postMessage(filedata, window.location); //向父窗体传递filedata数据
window.addEventListener("message", this.ListenerData, false); 接收程序有一个事件监听器,监听 "message" 事件,同时我们要验证消息来源地址,以确保是个可信的发送地址。
ListenerData(obj) { //obj 是子窗体传递filedata数据
}