Search code examples
javascriptjqueryhtmlprintjs

Is there anyway to wait for print window to close in print.js


I have some jquery code using print.js for printing an element and its working fine but I need to know if I can check if the print window is closed and reload the page

printJS('print_paper', 'html');
//do stuff after close print window

Solution

  • There is a option called onPrintDialogClose which is fire after Print dialog close.

    printJS({
        type: "html",  // Include other option if needed like style , css .....
        onPrintDialogClose: closedWindow 
      });
    }
    
    function closedWindow() {
      alert("Window is closed "); // What ever you want to do after window is closed .
    }