halpsb
halpsb

Reputation: 1106

JQuery printElement prints the whole page in Internet Explorer

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"); ?>'
            ]
        });
    });
});

Upvotes: 2

Views: 2037

Answers (1)

achudars
achudars

Reputation: 1506

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.

Upvotes: 1

Related Questions