2017-10-16 29 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

相關問題