1. 用media="print"的css来控制要打印的文件testPrint.html中引用media为print的样式,表示打印时该样式才起作用
复制代码 代码如下:
<link href="/style/print.css" type="text/css" media="print">
复制代码 代码如下:
.noprint{display:none;}
复制代码 代码如下:
<div>
<input type="button" value="打印本页" />
</div>
复制代码 代码如下:
<script type="text/javascript">
<!--
//自动在打印之前执行
window.onbeforeprint = function(){
$("#test").hide();
}
//自动在打印之后执行
window.onafterprint = function(){
$("#test").show();
}
//-->
</script>
<div>这段文字不会被打印出来</div>
新闻热点
疑难解答
图片精选