--- title: afterprint slug: Web/API/Window/afterprint_event translation_of: Web/API/Window/afterprint_event original_slug: Web/Events/afterprint ---

在相关联的文档已开始打印或打印预览已关闭之后, 触发 afterprint事件。

基本信息

Specification
HTML5
Interface
Event
Bubbles
No
Cancelable
No
Target
DefaultView (<window>)
Default Action
None

属性

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")}}

相关事件