<html>
<body>
<p>This example uses the addEventListener() method to attach an "afterprint" event to the window object.</p>
<h1>请尝试打印此文档</h1>
<p><b>提示:</b>键盘快捷键,例如 Ctrl+P,可设置要打印的页面。</p>
<p><b>注释:</b>Safari 和 Opera 不支持 afterprint 事件。</p>
<p><b>注释:</b>在 IE 中,afterprint 事件发生在打印对话框之前,而不是之后。</p>
<script>
window.addEventListener("afterprint", myFunction);
function myFunction() {
alert("This document is now being printed");
}
</script>
</body>
</html>