2017-10-16 1267 views

回答

1

window.print()不返回任何值。

我不认为有办法知道用户是否点击保存取消。这是你的操作系统更多的工作来观察那里正在发生的事情。还有的时候,然而,两个事件处理

  • window.onbeforeprint
  • window.onafterprint

代码段

window.onbeforeprint = function() { 
    console.log('This will be called before the user prints.'); 
}; 

window.onafterprint = function() { 
    console.log('This will be called after the user prints'); 
}; 

看看here

+0

感谢您的答复,但window.onafterprint功能在两种条件下跑出了用户点击是否要取消或打印button.so我觉得跟此功能我们无法检测到正确的行为,如果点击打印按钮。所以我已经使用了这个代码,但我没有运气 – sambath

+0

检查一次。 (“print”)。addListener(function(){ alert(“Print Dialog open。”) }); –

+0

谢谢,Ramu Bhusal。但对我而言没有结果。 – sambath

相关问题