jQuery.printElement icon indicating copy to clipboard operation
jQuery.printElement copied to clipboard

Chrome too fast for images

Open mb280sel1985 opened this issue 12 years ago • 1 comments

I've had trouble getting the plugin to work with chrome. The images are not loaded before the _callPrint function is called and Chrome is so quick that the images are not picked up in the preview.

The code inside function _printElement:

_callPrint(popupOrIframe);

..should be delayed until content of documentToWriteTo is done loading. The following fixed the problem:

REPLACE:

documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); _callPrint(popupOrIframe);

WITH:

documentToWriteTo.onload = _callPrint(popupOrIframe); documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close();

..and the _callPrint function is called right after all content has been loaded inside the documentToWriteTo window document.

Note: code sequence does matter

mb280sel1985 avatar Feb 07 '13 14:02 mb280sel1985

We solved this issue for our needs by modifying that function with a settimeout:

function _callPrint(element) { if (element && element.printPage) { /* compumatter inserted code. IE displayed blank page every time if no delay was inserted this was because 'print' was getting ahead of the iframe content being filled' */ setTimeout(function () { element.printPage(); }, 50); } else { setTimeout(function () { _callPrint(element); }, 50); } }

compumatter avatar Nov 19 '18 13:11 compumatter