Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Window
  4. afterprint

Window: afterprint event

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨September 2019⁩.

Theafterprint event is fired after the associated document has started printing or the print preview has been closed.

Thebeforeprint andafterprint events allow pages to change their content before printing starts (perhaps to remove a banner, for example) and then revert those changes after printing has completed. In general, you should prefer the use of a@media print CSS at-rule, but it may be necessary to use these events in some cases.

Syntax

Use the event name in methods likeaddEventListener(), or set an event handler property.

js
addEventListener("afterprint", (event) => { })onafterprint = (event) => { }

Event type

A genericEvent.

Examples

UsingaddEventListener():

js
window.addEventListener("afterprint", (event) => {  console.log("After print");});

Using theonafterprint event handler property:

js
window.onafterprint = (event) => {  console.log("After print");};

Specifications

Specification
HTML
# event-afterprint
HTML
# handler-window-onafterprint

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp