在javaScript中如何屏蔽不需要打印的项目?急!!!

wuxiaochun 2006-03-23 03:23:54
网页上要提供打印功能,如何屏蔽悼那些不需要的打印的内容。
special.style.display = "none"; 可以实现啊?怎么使用?
...全文
184 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuxiaochun 2006-03-23
  • 打赏
  • 举报
回复
meizz(梅花雪) singlezym() 谢谢!
clare2003 2006-03-23
  • 打赏
  • 举报
回复
在beforeprint和onafterprint()写

function window.onbeforeprint()
{
// Walk through all the elements in the document with
// CLASS="collapsed" and set it to "expanded" just for printing.
var coll = document.all.tags("DIV");
if (coll!=null)
{
for (i=0; i<coll.length; i++)
if (coll[i].className == "collapsed")
{
coll[i].className = "expanded";

// After printing, make sure to set CLASS="collapsed"
// only for those that were expanded just for printing.
coll[i].bExpandedForPrinting = true;
}

else if (coll[i].className == "expanded")
coll[i].bExpandedForPrinting = false;
}
}

function window.onafterprint()
{
// Walk through all the elements in the doc with CLASS="expanded"
// and set it to "collapsed" if expanded just for
// printing.
var coll = document.all.tags("DIV");
if (coll!=null)
{
for (i=0; i < coll.length; i++)
if ((coll[i].className == "expanded") &&
(coll[i].bExpandedForPrinting))
{
coll[i].className = "collapsed";
coll[i].bExpandedForPrinting = false;
}
}
}
singlezym 2006-03-23
  • 打赏
  • 举报
回复
<style media=print>
.Noprint{display:none;}
</style>
<center class="Noprint" >
。。不需要打印的内容
</center>
meizz 2006-03-23
  • 打赏
  • 举报
回复
<style>@media print {.btn{display: none;}}</style>
<input type=button value="上一页" class="btn">
<input type=button value="下一页" class="btn">

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧