Reputation: 235
hello i have a code for print, i do a window open, and this pop-up contain all info for print, and i using the kiosk-printing
for automatic printing but that fails sometime, if chrome is open with other instance for example, them i having problems because i need to confirm each print, then i need to know if exist a method for confirm what button press the client in Print Dialog(Print or Cancel).
var printWindow = window.open(windowUrl, windowName, 'left=500,top=100,width=10,height=10');
printWindow.document.body.innerHTML = HTL;
printWindow.document.close();
printWindow.focus();
printWindow.print(); // maybe here return if user press print or cancel
// if(ConfirmPrint=="print"){
// alert('Print Button');
//}else{
// alert('Cancel Button');
// }
Upvotes: 5
Views: 12395
Reputation: 1092
Sadly, window.print() doesn't return any value. So, there's no way to know if the user clicked Save or Cancel. It's more of your operating system's job to watch what's going on in there. There're, however, two event handlers: window.onbeforeprint and window.onafterprint.
The afterprint event is raised after the user prints or aborts a print dialog.
But again, it's a simple event and it's not telling you which option is selected by the user. And also these two events are not well supported.
Upvotes: 3