我目前正试图在父页面中打开的弹出窗口上添加事件侦听器。JavaScript:在父弹出窗口中添加事件侦听器
让我给你多一点解释:iframe中有一个按钮。单击此按钮时,在调用/保持iframe的父页面中打开一个弹出窗口。
这里是我的代码:
parent.window.open(url, "MyParentWindowPopUp", "width=1000, height=800");
有了这行代码我在父页面打开弹出窗口。
当窗户打开我要创建它所以这里的监听器是什么,当我添加一个侦听非父窗口使用:
if (window.addEventListener) {
window.addEventListener('message', <?php echo $_htmlId; ?>_receive_message, false);
} else if (window.attachEvent) {
window.attachEvent('onmessage', <?php echo $_htmlId; ?>_receive_message);
}
我怎样才能改变这种代码为工作父弹出窗口?
在此先感谢!