RitsC / PrintArea

jQuery plugin to print specified area of a page.
Other
264 stars 163 forks source link

Printing a JQuery Dialog in IE 10 #23

Closed Starkman68 closed 1 year ago

Starkman68 commented 9 years ago

There seems to be some issue when printing a jquery dialog when the dialog is set to Modal=true. If it is false everything works well. It it is set to true then the entire page with the dialog on top is printed.

The IFrame is created correctly in the DOM.

loueradun commented 7 years ago

It seems that the main document is being printed and not the iFrame document. I was able to fix this by replacing the print method with this:

print : function( PAWindow ) {
            var paWindow = PAWindow.win;

            $(PAWindow.doc).ready(function(){
                paWindow.focus();

                var ua = window.navigator.userAgent;
                var msie = ua.indexOf("MSIE ");

                if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
                    try {
                        paWindow.document.execCommand('print', false, null);
                    } catch (e) {
                        paWindow.printPage();
                    }
                } else {
                    paWindow.print();
                }

                if ( settings.mode == modes.popup && settings.popClose )
                    setTimeout(function() { paWindow.close(); }, 2000);
            });
        }