onbeforeprintEvent

事件对象参考手册Event Object

Example

Execute JavaScript when the page is about to be printed:

<body onbeforeprint="myFunction()">

Try it Yourself »


Definition and Usage

The onbeforeprint event is triggered 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()method.


Technical Details
Bubbles: No
Cancelable: No
Event type: Event
Supported HTML tags:  <body>


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