JS realizes page printing function
- 2021-08-05 08:09:28
- OfStack
Print the entire page
Example 1.
You can add and call the print method directly at the button:
<input type='button' value='打印整页' onclick='javascript:window.print();' />
Example 2.
You can also call the JS method
<html>
<head>
<script type="text/javascript">
function printpage()
{
window.print()
}
</script>
</head>
<body>
<input type="button" value="Print this page"
onclick="printpage()" />
</body>
</html>
On the window. print () method
The print () method is used to print the contents of the current window.