0

onload event not firing in IE 9 and above.

$(document).ready(function(){

        var popup = window.open('mypopup.html', 'bl', 'scrollbars=yes,location=no,toolbar=no,status=no,width=720,height=1000,left=300,top=50');
        var htmlToPrint = $('#thank_view').clone();
        htmlToPrint = htmlToPrint.html();

        popup.onload =function(){
            alert("ONLOAD WORKING");
            $("#appended", popup.document).append( htmlToPrint );
        }
});

I have also tried

  $(popup).on("load", function(){
        $("#appended", popup.document).append( htmlToPrint );
    });

All the above methods work in all browsers except IE9 and above. Is there a way around this for newer IE browsers.

Chapsterj
  • 6,483
  • 20
  • 70
  • 124
  • Does the load event not fire? Or is the HTML not appended? – gen_Eric Mar 27 '14 at 16:38
  • It is possible that `load` fires as soon as you call `.open()`. Does firing it manually _after you attach the handler_ work? – blgt Mar 27 '14 at 16:45
  • there is probably a X-Y problem, $(document).ready work well – ale Mar 27 '14 at 16:58
  • http://stackoverflow.com/questions/3030859/detecting-the-onload-event-of-a-window-opened-with-window-open – eithed Mar 27 '14 at 17:43
  • The load event is ignored from what I'm seeing. blgt what you mean firing it manually. – Chapsterj Mar 27 '14 at 18:04
  • Yup - came to same conclusions. Probably `popup.onload()`, but that doesn't work as well. I think you're stuck with `ready`, or having `load` inside `mypopup.html` (that works) – eithed Mar 27 '14 at 18:10
  • I tried $(popup.document).ready(function(){ and that fires but when you try to append something to a div inside popup it shows up as undefined. – Chapsterj Mar 27 '14 at 18:24
  • Also having load inside the popup is not much good when I'm appending data from the parent. But thanks for the suggestion. I find it hard to believe the only way is to poll it with a setInterval. That's an ugly hack – Chapsterj Mar 27 '14 at 18:25

0 Answers0