window.print() 分页
<html><head>
<title>打印</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--media=print 这个属性可以在打印时有效-->
<style media=print>
.Noprint{display:none;}
.PageNext{page-break-after: always;}
</style>
<script type="text/javascript">
function printit(){
//将部分隐藏不打印
document.getElementById("no").style.display = "none";
window.print();
//部分还原回来
document.getElementById("no").style.display = "";
return false;
}
</script>
</head>
<body >
<form>
<table width="90%" border="1" align="center" cellpadding="2" cellspacing="0" class="tabp">
<tr>
<td colspan="3" class="tdp">第1页</td>
</tr>
</table>
<hr>
<!--分页-->
<div class="PageNext"></div>
<table width="90%" border="1" align="center" cellpadding="2" cellspacing="0">
<tr>
<td class="tdp">第2页</td>
</tr>
<tr>
<td class="tdp">看到分页了吧 打印分页实际是控制CSS而以..调用样式后自然分面打印了...
</td>
</tr>
</table>
<div id="no">
<input type=button value=打印分页 >
</div>
</form>
</body>
</html>
页:
[1]