--- title: afterprint slug: Web/API/Window/afterprint_event translation_of: Web/API/Window/afterprint_event original_slug: Web/Events/afterprint ---
在相关联的文档已开始打印或打印预览已关闭之后, 触发 afterprint事件。
<window>)| Property | Type | Description |
|---|---|---|
target {{readonlyInline}} |
{{domxref("EventTarget")}} | The event target (the topmost target in the DOM tree). |
type {{readonlyInline}} |
{{domxref("DOMString")}} | The type of event. |
bubbles {{readonlyInline}} |
{{jsxref("Boolean")}} | Whether the event normally bubbles or not. |
cancelable {{readonlyInline}} |
{{jsxref("Boolean")}} | Whether the event is cancellable or not. |
使用 addEventListener():
window.addEventListener('afterprint', (event) => {
console.log('After print');
});
使用 onafterprint 时间监听属性:
window.onafterprint = (event) => {
console.log('After print');
};
| Specification | Status |
|---|---|
| {{SpecName('HTML WHATWG', '#event-afterprint')}} | {{Spec2('HTML WHATWG')}} |
{{Compat("api.Window.afterprint_event")}}