IE11 Windows 7 Print issue after kb4021558

andyfinch picture andyfinch · Jun 14, 2017 · Viewed 26.8k times · Source

Apologies for the slightly vague question but I'm pulling my hair out. Since this update we have had numerous calls regarding printing from our web app. Our web app uses an iframe and we use css @media print to hide all but this iframe for printing purposes. Since the update the user receives an Error 404--Not Found instead of the actual page. It would seem from the network trace that IE creates a temp .htm file in the local directory like D3CD911.htm, it then downloads css/js resources and then finally it makes this call /D3CD911.htm. This is making a call to www.mywebsite.co.uk/D3CD911.htm. This obviously does not exist on the website so the 404 is returned. I struggling to find a pattern to the problem and it doesn't seem to be affecting other public sites. I think the issue is with window.print() method. I can semi reproduce it here at https://www.primefaces.org/showcase/ui/misc/printer.xhtml. If you click the print button you will get the error. Although this is using the jqprint javascript function if you then use the browser print button it also fails.

Any guidance would be much appreciated.

Answer

Thom picture Thom · Jun 15, 2017

andyfinch, you're a genius! The following code appears to work for a print button contained within a frame:

function Print() {
  if (document.queryCommandSupported('print')) {
    document.execCommand('print', false, null);
  }
  else {
    window.parent.<framename>.focus();
    window.print();
  }
}