Print function in Chrome no longer working Print function in Chrome no longer working google-chrome google-chrome

Print function in Chrome no longer working


The button and the window.open really have nothing to do with your problem.

The problem is, Chrome is looking for user input before it prints. Window.print() opens the print dialog window, but Chrome isn't waiting for you to finish printing. The window.close() is closing the print dialog window and everything else in the parent.

In an effort to save you time, be aware that the OnAfterPrint hook isn't used by Chrome at all. I also tried putting window.close() in the onLoad and window.print() in the onBeforeUnload, but the print dialog cancels the window.close(). The next best thing would be to do something like:

//In your profile print page<html><head><script>var is_chrome = function () { return Boolean(window.chrome); }if(is_chrome) {   window.print();   setTimeout(function(){window.close();}, 10000);    //give them 10 seconds to print, then close}else{   window.print();   window.close();}</script><body onLoad="loadHandler();">

I haven't tested this, but I think it demonstrates the idea fairly effectively.


I found this solution and it really works:

<body onload="window.print();window.onmouseover = function() { self.close(); } ">


I use Mr.bresleveloper solution with some changes:

var is_chrome = Boolean(window.chrome);if (is_chrome) {    winPrint.onload = function () {        setTimeout(function () { // wait until all resources loaded             winPrint.print();  // change window to winPrint            winPrint.close();// change window to winPrint        }, 200);    };}else {    winPrint.print();    winPrint.close();}