使用css print属性实现强制分页功能的时候一定要记得打印的内容外层只有一个容器 ,外层有两个div容器,打印的时候css print属性就不起任何作用。
<html lang="en">
<head>
<meta charset="UTF-8">
<title>打印 </title>
<script type="text/javascript">
function Print(){
window.print();
}
</script>
</head>
<body>
<div><input type="button" value="打印" onclick="Print()" /></div>
<div id="page1">
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="page-break-after:always" >
<tr><td>第一页打印内容</td></tr>
</table>
</div>
<div id="page2">
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="content" >
<tr><td>第二页打印内容</td></tr>
</table>
</div>
</body>
</html>