Window print() Method - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window print

Description

The print() method prints the contents of the current windowby opening the Print Dialog Box, which lets the user to select preferred printing options.

Parameters

None

Return Value:

No return value

The following code shows how to Print the current page:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Print this page</button>

<script>
function myFunction() {/* ww  w.ja v  a2 s  . c om*/
    window.print();
}
</script>

</body>
</html>

Related Tutorials