esafwan
esafwan

Reputation: 18029

Js print function not working in ie9

I have the below code to print the text that is loaded in fancybox. It works perfect in chrome and firefox. But in ie9 it opens a blank window and closes. Then nothing happends.

jQuery(function($) {
    $('a.print').click(function() {
        var print_button = '';
        var print_page = window.open('', 'Print', 'width=600,scrollbars=yes, height=700');
        var html = '<h2><?php print t("Term & Condition"); ?></h2> <br/>' + '<?php echo $body_content; ?>';
        print_page.document.open();
        print_page.document.write(html);
        print_page.print();
        print_page.close();
        return false;
    });
});

Upvotes: 0

Views: 2243

Answers (2)

MarcoK
MarcoK

Reputation: 6110

Change the following:

print_page.document.write(html);
print_page.print();

into:

print_page.document.write(html);
print_page.document.close();
print_page.focus();
print_page.print();

JSFiddle.

Upvotes: 2

chridam
chridam

Reputation: 103365

Try adding <meta http-equiv="X-UA-Compatible" content="IE8"/> at head section so that the page renders in IE8 mode and check if it helps.

Upvotes: 0

Related Questions