title: addEventListener does not work in IE 11
body: <p>I am using javascript to open a popup and execute some code once it is loaded.</p>
  
  <p>This is the code:</p>
  
  <pre><code>// Öffnen des Print Popups binden.
  $('#revi_print').unbind();
  $('#revi_print').click(function() {
  
      // Popup erstellen.
      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");
  
      // Code erst ausführen, wenn das Popup geladen ist.
      popup.addEventListener('load', handle_popup, false);
  });
  </code></pre>
  
  <p>It does work fine in Firefox and Google Chrome, however I have realized, that it does not work in the newest Internet Explorer.</p>
  
  <p>From what I have read, addEventListener should be supported above IE9, so theoretically IE 11 should support it - however it seems this is not the case.</p>
  
  <hr>
  
  <p>This error indicates, that IE11 is not supporting the method...</p>
  
  <p><a href="https://i.stack.imgur.com/Qfli8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qfli8.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p>Is there a simple workaround to make this work?</p>
  
  <hr>
  
  <p>I have just tried this pice of code:</p>
  
  <pre><code>if (popup.addEventListener){
      alert("firefox, chorome, etc");
      popup.addEventListener('load', handle_popup, false); 
  } else if (popup.attachEvent){
      alert("IE");
      popup.attachEvent('load', handle_popup);
  }   
  </code></pre>
  
  <p>Apparently this should work according to different other threads, but it is not the case. The browser does go to the else if, when IE is used - however it still refuses to work.</p>
  
  <p>Could it be, that attachEvent in IE does not work on popups?</p>
  
  <p><a href="https://i.stack.imgur.com/KcZkv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KcZkv.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p>I have just tried the method indicated in the first answer.</p>
  
  <p>It works in firefox and chrome, but IE refuses to work, even tough this method does not have the EventListener any more:</p>
  
  <pre><code>// Öffnen des Print Popups binden.
  $('#revi_print').unbind();
  $('#revi_print').click(function() {
  
      // Popup erstellen.
      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");
  
      // Code erst ausführen, wenn das Popup geladen ist.
      //popup.addEventListener('load', handle_popup, true);
  
      popup.window.onload=function() { parent.handle_popup(popup); }
  });
  
  // Code zum handeln des Popups.
  function handle_popup(popup) {
      var selected_report = $('#revi').data('filter_report');
      var jqplot_object = $('#revi_filter_ddReport_' + selected_report + '_jqplot_object').html();
      var has_chart = $('#revi_filter_ddReport_' + selected_report + '_has_chart').html();
      var obj = $.parseJSON($('#revi').data('data').trim());
  
      // Den Kontent kopieren.
      popup.$('#revi_sec_report_container').html($('#revi_report_container').html());
  
      // Den Print Button entfernen.
      popup.$('#revi_print').remove();
  
      // Das chart entfernen.
      popup.$('#revi_chart').empty();
  
      // Wenn ein Chart gezeichnet werden soll.
      if (has_chart == 1) { 
          var execute_string = $.base64.decode(jqplot_object);
          eval(execute_string); 
      }
  }
  </code></pre>
  
  <hr>
  
  <p>Next attempt (half successful):</p>
  
  <p>I have added this line of code to the HTML of the POPUP:</p>
  
  <p><a href="https://i.stack.imgur.com/9pwUe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9pwUe.png" alt="enter image description here"></a></p>
  
  <p>This are the changes on the javascript side:</p>
  
  <pre><code>// Öffnen des Print Popups binden.
  $('#revi_print').unbind();
  $('#revi_print').click(function() {
  
      // Popup erstellen.
      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");
  
      $('body').data('the_popup', popup);
  
      // Code erst ausführen, wenn das Popup geladen ist.
      //popup.addEventListener('load', handle_popup, true);
  
      //window.onload=function() { handle_popup(popup); }
  });
  
  // Code zum handeln des Popups.
  function handle_popup() {
  
      var popup = $('body').data('the_popup');
  
      var selected_report = $('#revi').data('filter_report');
      var jqplot_object = $('#revi_filter_ddReport_' + selected_report + '_jqplot_object').html();
      var has_chart = $('#revi_filter_ddReport_' + selected_report + '_has_chart').html();
      var obj = $.parseJSON($('#revi').data('data').trim());
  
      // Den Kontent kopieren.
      popup.$('#revi_sec_report_container').html($('#revi_report_container').html());
  
      // Den Print Button entfernen.
      popup.$('#revi_print').remove();
  
      // Das chart entfernen.
      popup.$('#revi_chart').empty();
  
      // Wenn ein Chart gezeichnet werden soll.
      if (has_chart == 1) { 
          var execute_string = $.base64.decode(jqplot_object);
          eval(execute_string); 
      }
  }
  </code></pre>
  
  <p>On firefox and Chrome it works perfectly, the popup opens, and the chart that should be drawn on the popup shows up.</p>
  
  <p>Now IE also executes the code for the popup, which is very good, but now only for IE JQPLOT does throw an error somewhere in the library.</p>
  
  <p>I have no clue why this happens, I can only guess that the popup is not jet finished loading, when the code for jqplot is executed.</p>
  
  <hr>
  
  <p>Got everything working now - the jqplot thing is fixed now...</p>