简体   繁体   English

Js打印功能在ie9中不起作用

[英]Js print function not working in ie9

I have the below code to print the text that is loaded in fancybox. 我有以下代码来打印在fancybox中加载的文本。 It works perfect in chrome and firefox. 它在chrome和firefox中非常完美。 But in ie9 it opens a blank window and closes. 但在ie9中它打开一个空白窗口并关闭。 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;
    });
});

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 . JSFiddle

尝试在头部添加<meta http-equiv="X-UA-Compatible" content="IE8"/> ,以便页面呈现在IE8模式下并检查它是否有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM