Nos bénévoles n'ont pas encore traduit cet article en Français. Inscrivez-vous et aidez-nous à réaliser cette tâche !
Vous pouvez également lire cet article en English (US).

 

Summary

The property onbeforeprint sets and returns the onbeforeprint event handler code for the current window.

Syntax

window.onbeforeprint = event handling code

Notes

Some browsers (including Firefox 6 and later and Internet Explorer) send beforeprint and afterprint events to let content determine when printing may have occurred. You can use this to adjust the user interface presented during printing (such as by displaying or hiding user interface elements during the print process).

The event beforeprint is raised before the print job dialog appears.

For Webkit-based browsers, you can create an equivalent result with window.matchMedia('print').

var mediaQueryList = window.matchMedia('print');
mediaQueryList.addListener(function(mql) {
  if(mql.matches) {
    console.log('webkit equivalent of onbeforeprint');
  }
});

 

Specification

Specification Status Comment
HTML Living Standard
The definition of 'onbeforeprint' in that specification.
Living Standard  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support63 Yes6 Yes No No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes ? No ? ?

See also

 

Étiquettes et contributeurs liés au document

Étiquettes : 
Dernière mise à jour par : greypants,