在FireFox和Internet Explorer中,您可以侦听打印后事件。
window.onafterprint = function(){ console.log("Printing completed...");}可能可以使用window.matchMedia在其他浏览器中获得此功能。
(function() { var beforePrint = function() { console.log('Functionality to run before printing.'); }; var afterPrint = function() { console.log('Functionality to run after printing'); }; if (window.matchMedia) { var mediaQueryList = window.matchMedia('print'); mediaQueryList.addListener(function(mql) { if (mql.matches) { beforePrint(); } else { afterPrint(); } }); } window.onbeforeprint = beforePrint; window.onafterprint = afterPrint;}());


