[英]check if the page print has been printed and then close it
I want to check if the page has been printed and then close it.我想检查该页面是否已打印,然后将其关闭。 I searched a lot but there is no answer I tried:我搜索了很多,但没有我试过的答案:
1- window.matchMedia('print') but it return always false.
2-window.onafterprint it doesn't work anymore.
3- I can not create a new doc and insert body of my page in it because my page comes from Crystelreport and it does have a barcode. 3- 我无法创建新文档并在其中插入我的页面正文,因为我的页面来自 Crystelreport 并且它确实有条形码。
My code is simple:我的代码很简单:
var win = window.open(url, 'popup', 'toolbar = no, status = no, scrollbars = yes, resizable = yes');
win.onafterprint = function () {
win.close();
}
Try this:尝试这个:
var win = window.open(url, 'popup', 'toolbar = no, status = no, scrollbars = yes, resizable = yes');
win.onafterprint = function (e) {
e.target.close();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.