直接上代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>打印页面</title>
</head>
<body>
<h1>这是不打印部分</h1>
<div class="print" style="text-align:center; margin-top: 30px">
<div id="printArea">
<div>......文本打印区域......</div>
<div>......文本打印区域......</div>
<div>......文本打印区域......</div>
<div>......文本打印区域......</div>
<div>......文本打印区域......</div>
</div>
<br>
<br>
<input type="button" media="print" value="打印" onclick="printArea()">
<input id="btnPrintFull" type="button" value="全屏打印">
</div>
</body>
<script>
function printArea(){
//设置body隐藏,并设置打印区域为可见
document.body.style.visibility='hidden';
document.getElementById('printArea').style.visibility='visible';
window.print();
location.href='打印测试.html'
return false;
}</script>
</html>