1

This code works in IE Edge and the latest version of FF but not in the latest version of Chrome (it worked a few months ago, don't know which version I was on).

In Chrome the print preview page comes up but just shows a blank page.

I've tried Chrome print blank page but that didn't help. What else can I try?

jQuery('#print-me').click(function(){
    var printPreview = window.open();
    printPreview.document.open();
    printPreview.document.write("<!DOCTYPE html>"+
           "<html>"+
           "<head>"+
           "</head>"+
           "<body><p>hello</p></body>"+
           "</html>");

    printPreview.document.close();
    printPreview.print();
    printPreview.close();   

    return false;
  });
Community
  • 1
  • 1
KevinUK
  • 5,053
  • 5
  • 33
  • 49

1 Answers1

1

I put your code as is below quickly onto codepen and it worked without issue on chrome 47.0.2526.111 m (64-bit). I just made a div to check if it worked, and no problem. http://codepen.io/prophet60091/pen/bEvpaj

This I want to print
jQuery('#print-me').click(function(){
var printPreview = window.open();
printPreview.document.open();
printPreview.document.write("<!DOCTYPE html>"+
       "<html>"+
       "<head>"+
       "</head>"+
       "<body><p>hello</p></body>"+
       "</html>");

printPreview.document.close();
printPreview.print();
printPreview.close();   

return false;

});

Not sure but maybe it be your jquery version giving you fits?

Robert Jackson
  • 131
  • 2
  • 9