beforeprint

翻译正在进行中。

当相关联的文档即将打印或预览以进行打印时,将触发beforeprint事件。

基本信息

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

属性

属性 类型 描述
target 只读 EventTarget 事件目标 (DOM 树中的最顶层目标)
type 只读 DOMString 时间类型
bubbles 只读 Boolean 事件是否冒泡
cancelable 只读 Boolean 事件是否可取消

样例

使用 addEventListener()

window.addEventListener('beforeprint', (event) => {
  console.log('Before print');
});

使用 onbeforeprint 事件监听属性:

window.onbeforeprint = (event) => {
  console.log('Before print');
};

规范

Specification Status
HTML Living Standard Living Standard

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
beforeprint eventChrome Full support 63Edge Full support 12Firefox Full support 6IE Full support YesOpera Full support 50Safari Full support 13WebView Android Full support 63Chrome Android Full support 63Firefox Android ? Opera Android Full support 46Safari iOS Full support 13Samsung Internet Android Full support 8.0

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

相关事件