例子
代码
<!DOCTYPE html>
<html>
<head>
<title>js打印去除页眉页脚</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://cdn.bootcss.com/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<button onclick="divPrint()">打印</button>
<div id="print">
我是要打印的内容
</div>
<script type="text/javascript">
function divPrint() {
var WinPrint = window.open('', '', 'left=0,top=0, toolbar=0,scrollbars=0,status=0');
WinPrint.document.write($('#print').html());
WinPrint.document.write('<style>html{padding:1cm;}@page {margin:0};</style>');
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
</script>
</body>
</html>
本文链接地址: js局部打印去除页面页脚