JQuery printElement在Internet Explorer中打印整个页面 [英] JQuery printElement prints the whole page in Internet Explorer

查看:203
本文介绍了JQuery printElement在Internet Explorer中打印整个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 jQuery printElement 来打印div的内容。

它在Safari,Chrome和Firefox上运行良好,但是当我尝试使用Internet Explorer(所有版本)时,它仅打印整个页面而不是div。这是为什么?我可以做什么?



以下是用于打印的代码:

  $('。print_button')。each(function(){
$(this).click(function(){
$(this).closest('。details')。find(' printElement({
pageTitle:'...',
overrideElementCSS:[
'<?php echo stylesheet_path(print.css);?>'
]
});
});
});


解决方案

您是否使用过简单的CSS:

  @media print {
.element-not-to-print {
display:none;


$ / code $ / pre
$ b $ / $

  @media print {
.element-not-to-print {
visibility:hidden;


code


支持媒体查询是 IE9 + http://caniuse.com/css-mediaqueries



对于IE7和IE8,请使用选中这篇文章。或者直接添加此JavaScript文件到您的项目中,继续使用不会像jQuery一样杀死您的性能的旧版媒体查询。


I am using jQuery printElement in order to print the content of a div.

It's working perfectly on Safari, Chrome and Firefox but when I try with Internet Explorer (all versions), it prints the whole page instead of the div only. Why is that? What can I do?

Here's the code used to print :

$('.print_button').each(function() {
    $(this).click(function() {
        $(this).closest('.details').find('.div_to_print').printElement({
            pageTitle: '...',
            overrideElementCSS: [
                '<?php echo stylesheet_path("print.css"); ?>'
            ]
        });
    });
});

解决方案

Have you tried using simply CSS:

@media print {
      .element-not-to-print {
          display: none;
      }
}

OR

@media print {
      .element-not-to-print {
          visibility: hidden;
      }
}

Support for Media Queries is IE9+ : http://caniuse.com/css-mediaqueries

For IE7 and IE8 use check this article. Or just go straight to the point by adding this JavaScript file to your project and continue using the good old Media Queries that will not kill your performance like jQuery.

这篇关于JQuery printElement在Internet Explorer中打印整个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆