onbeforeprintEvent

事件对象参考手册Event Object

Examples

Execute JavaScript when the page is about to be printed:

<body onbeforeprint="myFunction()">

Try it yourself »


Definition and Usage

The onbeforeprint event fires when the page is about to be printed (before the print window appears).

Tip:The opposite event of the onbeforeprint event isonafterprint 。


Browser Support

Event
onbeforeprint Not supported Yes Yes Not supported Not supported


Syntax

In HTML:

<element onbeforeprint="myScript">Try it yourself

In JavaScript:

object.onbeforeprint=function(){myScript};Try it yourself

In JavaScript, using the addEventListener() method:

object.addEventListener("beforeprint", myScript);Try it yourself

Note:Internet Explorer 8 and earlier IE versions do not supportaddEventListener()the method.


Technical Details
Does it support bubbling: No
Can it be canceled: No
Event type: Event
Supported HTML tags:  <body>


事件对象参考手册Event Object Other Extensions