Window:print() 方法

Baseline 2023
Newly available

Since June 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

打开打印对话框,以打印当前文档。

如果调用此函数时文档仍在加载中,那么文档将在打开打印对话框之前完成加载。

当打印对话框打开时,此方法将阻塞。

语法

js
print()

参数

返回值

无(undefined)。

规范

Specification
HTML
# printing

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
print

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

参见

  1. 打印
  2. beforeprint 事件
  3. afterprint 事件