Open SteveDonkin opened 12 years ago
I was also researching the ie7 print problem and found this suggestion - http://bytes.com/topic/misc/answers/629926-ie7-printing-iframe-solution - and dropped it into the source.
html.push('');
and this has fixed IE7 for me. document.execCommand isn't something I had previously considered, because it's normally in the realm of contentEditable areas - but a neat find. Seems to still work in other browsers I tested too!
Hey this also happens on IE9 but I found a little "fix" Just add a timeout near the end of the file:
html.push('');
I wasn't sure about the 2nd part with the if statement, but I got rid of the true condition temporarily because in chrome the preview screen with close before I could hit print. Someone else can look at that. Unfortunately I have to move onto another project.
Seems that sometimes on IE after clearing the cache with the developer tools or having a browser that has never been to the site before - the first time we attempt to print the element (which is a fancybox in a div to give a popup using css) the main page is printed instead of the selected element. My colleague figured out that in some cases the Iframe wasn't created before the print happens. It was quite odd, but seems to be fixed using the onload function which ensures the page is rendered before the printing gets called. It fixed the issue for us. Was a bit of an odd one, but might help others. I wondered if similar issues could be fixed using onload instead of timeout, I didn't fully investigate which browsers would support onload but I think it's been around a while so should have good support.
e.g. function _callPrint(element) { if (element && element["printPage"]) // element["printPage"]();
element.onload= function() { element["printPage"](); }
else setTimeout(function () { _callPrint(element); }, 50); }