第一种:用样式表(CSS)控制
testprint1.htm
<html>
<head><title>测试样式表控制打印</title></head>
<style type="text/css">
@media print {
.ptn {display:block;}
.noptn {display:none;}
}
</style>
<div class="noptn">这里不打印</div>
<div class="ptn">这里打印</div>
<body>
</body>
</html>
testprint2.html
<html>
<head><title>测试JS控制打印</title></head>
<script language="javascript">
function ptn(){
btn.style.display='none';
window.print();
btn.style.display='';
}
</script>
<body>
<input type="button" id="btn" value="点击我打印后不会出现在纸上" onclick="ptn()">
</body>
</html>
本文地址:http://com.8s8s.com/it/it31153.htm