<body onbeforeprint="myFunction()"> - Javascript DOM Event

Javascript examples for DOM Event:onbeforeprint

Introduction

The onbeforeprint event occurs when a page is about to be printed.

Summary

Bubbles No
Cancelable No
Supported HTML tags: ?<body>

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body onbeforeprint="myFunction()">

<h1>Try to print this document</h1>

<script>
function myFunction() {/*from   w w w . j  a v a  2s  .  c  om*/
    console.log("You are about to print this document!");
}
</script>

</body>
</html>

Related Tutorials