erikzaadi / jQueryPlugins

Collection of jQuery plugins
83 stars 88 forks source link

Internet Explorer (all versions) prints the whole page instead of the selected div only #55

Closed achudars closed 5 years ago

SeanLMcCullough commented 6 years ago

(Super late to the party here)

I've found that Internet Explorer won't allow for print() on iframes. So you need to use mywindow.document.execComand('print',false,null);

However, this stops it from working in Firefox.

If you only need to support IE and Chrome (have tested both work), you can use the following replacing line 176; html.push('<script type="text/javascript">function printPage(){var printed=false;focus();if(this.document.execCommand){this.document.execCommand("print",false,null);printed=true;}if(!printed){print();}' + ((!opts["leaveOpen"] && opts["printMode"].toLowerCase() == 'popup') ? 'close();' : '') + '}</script>');