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>
新聞熱點
疑難解答
圖片精選