print control with css and javascript

Sometimes we have to print a web document without some elements on it.
We can utilize gumptious css style or JavaScripts to accomplish  this task that seemed be difficult.
1)css:
css style part:
<style media=print type=css/style>
.NotPrint 
{display:none}
</style>
html part:
None.gifdot.gif
None.gif
<div class=NotPrint id="NotPrintPart">
None.gif<!--some innerHtml !-->
None.gif
</div>
None.gifdot.gif

2)Javascript:
Javascript part:
 1None.giffunction onBeforePrint()
 2ExpandedBlockStart.gifContractedBlock.gifdot.gif{
 3InBlock.gifdocument.all.NotPrintPart.style.display="none";
 4InBlock.gif//or
 5InBlock.gif//document.all.NotPrintPart.style.visibility="hidden";
 6ExpandedBlockEnd.gif}

 7None.gif
 8None.giffunction onAfterPrint()
 9ExpandedBlockStart.gifContractedBlock.gifdot.gif{
10InBlock.gifdocument.all.NotPrintPart.style.display="";
11InBlock.gif//or
12InBlock.gif//document.all.NotPrintPart.style.visibility="visible";
13ExpandedBlockEnd.gif}

14None.gif
15None.gif
html part:
None.gifdot.gif
None.gif
<body onBeforePrint="onBeforePrint()" onAfterPrint="onAfterPrint()">
None.gifdot.gif
    <div id=NotPrintPart ></div>

转载于:https://www.cnblogs.com/webq/archive/2005/12/16/298399.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值