addEventListener does not work in IE 11

只愿长相守 提交于 2019-12-02 02:47:19

Sounds like a dupe of Detecting the onload event of a window opened with window.open

but I could not see a specific answer of your question in it.

But why not do

window.onload=function() { opener.handle_popup() } // or attachEventListener

in the child window? Not need for attach events that may never be triggered because your attaching may be after the load triggered

TRY IT

Tested and working (after allowing popups) in Chrome Edge, IE11 and FX

NVCoder

As explained in "https://github.com/angular/zone.js/issues/535", another reason sometimes is that IE takes time to return the window object returned by window.open. As a result by the time your addEventlistener code executes, the object doesn't have this function. The workaround I used was:

popup = window.open('report_handle/print.php?filter_report=' + $('#revi').data('filter_report'), "Popup", "width=1024, height=768, scrollbars=yes, toolbar=no, status=no, resizable=yes, menubar=no, location=no, directories=no, top=10, left=10");
var interval = setInterval(function(){
   if(typeof popup.addEventListener === "function"){
   clearInterval(interval);
    popup.addEventListener('load', handle_popup, false);
   }
},100);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!