The print()
method opens the Print Dialog Box.
print |
Yes | Yes | Yes | Yes | Yes |
window.print()
None.
No return value.
The following code shows how to Print the current page.
<!DOCTYPE html>
<html>
<body>
<!-- ww w .j a v a 2 s. co m-->
<button onclick="myFunction()">Print this page</button>
<script>
function myFunction() {
window.print();
}
</script>
</body>
</html>
The code above is rendered as follows: