addEventListener does not work in IE 11

I am using javascript to open a popup and execute some code once it is loaded.

This is the 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);
});

It does work fine in Firefox and Google Chrome, however I have realized, that it does not work in the newest Internet Explorer.

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.


This error indicates, that IE11 is not supporting the method…

enter image description here


Is there a simple workaround to make this work?


I have just tried this pice of 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);
}   

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.

Could it be, that attachEvent in IE does not work on popups?

enter image description here


I have just tried the method indicated in the first answer.

It works in firefox and chrome, but IE refuses to work, even tough this method does not have the EventListener any more:

// Ö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); 
    }
}

Next attempt (half successful):

I have added this line of code to the HTML of the POPUP:

enter image description here

This are the changes on the javascript side:

// Ö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); 
    }
}

On firefox and Chrome it works perfectly, the popup opens, and the chart that should be drawn on the popup shows up.

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.

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.


Got everything working now – the jqplot thing is fixed now…

180 thoughts on “addEventListener does not work in IE 11”

  1. You can definitely see your enthusiasm within the paintings you write. The world hopes for more passionate writers such as you who are not afraid to mention how they believe. Always follow your heart.

    Reply
  2. I just couldn’t go away your website before suggesting that I really enjoyed the standard information an individual supply for your visitors? Is gonna be back continuously to investigate cross-check new posts.

    Reply
  3. It is perfect time too maske a ffew plans
    foor tthe future andd it’s tine to bbe happy.
    I’ve learrn thuis submit aand iff I mayy I want too counse you sme attention-grabbing thints orr advice.
    Maytbe yyou cojld wrige next afticles rlating to this article.
    I wnt tto rad more issues aboout it!

    Reply
  4. Its like you read my thoughts! You seem to know so much about this, like you wrote the
    e book in it or something. I think that you could do with a
    few percent to drive the message house a little bit, however instead of that,
    this is magnificent blog. A fantastic read. I will definitely
    be back.

    Reply
  5. I just could not go away your web site before suggesting that I really loved the standard information a person provide in your visitors? Is going to be back ceaselessly to investigate cross-check new posts.

    Reply
  6. Howdy just wanted to give you a quick heads up and let you
    know a few of the pictures aren’t loading properly. I’m not sure why but I think its a linking issue.
    I’ve tried it in two different browsers and both show the same
    outcome.

    Reply
  7. Hello There. I found your blog using msn. This is an extremely well written article.

    I will be sure to bookmark it and return to read more of your useful information. Thanks for the post.
    I’ll certainly comeback.

    Reply
  8. My developer is trying to persuade me to move
    to .net from PHP. I have always disliked the idea because of the
    expenses. But he’s tryiong none the less. I’ve been using Movable-type on a variety of websites for about a
    year and am nervous about switching to another platform.
    I have heard great things about blogengine.net.

    Is there a way I can import all my wordpress content
    into it? Any kind of help would be greatly appreciated!

    scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

    Reply
  9. Pingback: gay dating karachi
  10. Hey, I think your blog might be having browser compatibility issues.
    When I look at your website in Chrome, it looks fine but when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up!
    Other then that, wonderful blog!

    Reply
  11. I will right away take hold of your rss as I can not in finding your email
    subscription link or e-newsletter service. Do you have any?
    Please allow me recognize in order that I may just
    subscribe. Thanks.

    Reply

Leave a Comment