admin管理员组文章数量:1401664
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');
// }
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');
// }
Share
Improve this question
asked Sep 21, 2015 at 1:07
jearcajearca
2351 gold badge4 silver badges13 bronze badges
2
- This might help you. – J Santosh Commented Sep 21, 2015 at 2:16
- 2 it's almost 2021 and I still can't know if my user is clicking a button !? – user12163165 Commented Aug 31, 2020 at 22:27
1 Answer
Reset to default 3Sadly, 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.
本文标签: javascriptDetect if windowprint is confirm or cancelStack Overflow
版权声明:本文标题:javascript - Detect if window.print is confirm or cancel - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744264437a2597878.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论