Javascript 手柄';关闭';“打印事件”对话框
我正在使用并希望处理打印对话框(Chrome、Firefox等)的“关闭”事件。我试过了Javascript 手柄';关闭';“打印事件”对话框,javascript,jquery,Javascript,Jquery,我正在使用并希望处理打印对话框(Chrome、Firefox等)的“关闭”事件。我试过了 window.onclose = function(){ // do something } 但它没有起作用 有什么办法吗 欢迎任何解决方案。执行此操作 window.print() //or whatever you want to do window.onfocus=function(){ //user is back } window.print() //open the print dia
window.onclose = function(){
// do something
}
但它没有起作用
有什么办法吗
欢迎任何解决方案。执行此操作
window.print() //or whatever you want to do
window.onfocus=function(){
//user is back
}
window.print() //open the print dialog box
window.onafterprint=function(){
//do whatever it is you wish to do
}
注意
这只适用于Firefox(>6.0)和Internet Explorer
对于包括Chrome在内的其他浏览器,请尝试window.matchMedia()
@这不是我的情况。我在LinuxIt上使用Chrome 51,只有在切换浏览器选项卡时才会触发。windows上的Chrome。谢谢,但它不起作用,我在LinuxNoLuck上使用Chrome51。我正在使用Printarea插件,嗯。
window.print() //open the print dialog box
var printEvent = window.matchMedia('print');
printEvent.addListener(function(printEnd) {
if (!printEnd.matches) {
// do whatever you wish to do
};
});