<inputid="btnPrint" type="button" value="打印"onclick="javascript:window.print();" />
<inputid="btnPrint" type="button" value="打印预览" onclick=preview(1)/>
<styletype="text/css" media=print>
.noprint{display : none}
</style>
<pclass="noprint">不须要打印的地方</p>
<script>
functionpreview(oper)
{
if (oper <10)
{
bdhtml=window.document.body.innerHTML;//获取当前页的html代码
sprnstr="<!–startprint"+oper+"–>";//设置打印開始区域
eprnstr="<!–endprint"+oper+"–>";//设置打印结束区域
prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18);//从開始代码向后取html
prnhtmlprnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
window.document.body.innerHTML=prnhtml;
window.print();
window.document.body.innerHTML=bdhtml;
} else {
window.print();
}
}
</script>
<p>XXXXX</p>
<!–startprint1–>要打印的内容<!–endprint1–>
<inputid="btnPrint" type="button" value="打印"onclick="javascript:window.print();" />
<inputid="btnPrint" type="button" value="打印预览" onclick=preview(1)/>
<styletype="text/css" media=print>
.noprint{display : none}
</style>
<pclass="noprint">不须要打印的地方</p>
<script>
functionpreview(oper)
{
if (oper <10)
{
bdhtml=window.document.body.innerHTML;//获取当前页的html代码
sprnstr="<!–startprint"+oper+"–>";//设置打印開始区域
eprnstr="<!–endprint"+oper+"–>";//设置打印结束区域
prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18);//从開始代码向后取html
prnhtmlprnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
window.document.body.innerHTML=prnhtml;
window.print();
window.document.body.innerHTML=bdhtml;
} else {
window.print();
}
}
</script>
<p>XXXXX</p>
<!–startprint1–>要打印的内容<!–endprint1–>

最新文章

  1. JavaScript 垃圾回收
  2. WEBPACK开始
  3. The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit
  4. 《OD大数据实战》Sqoop入门实例
  5. memcpy与memmove区别
  6. /etc/motd and /etc/issue
  7. rsync指令详解
  8. php对象中类的继承性访问类型控制
  9. ng-class 用法
  10. 微信小程序多宫格抽奖
  11. 协议端口号(protocol port number)
  12. Vue组件库 VV-UI 开始接受PR啦,有兴趣小伙伴可以一起参与开源哦。
  13. codeforces 868B Race Against Time
  14. idea中的一些快捷键,未完待续......
  15. c#管理文件系统
  16. 记账本NABCD分析
  17. c++11 function_typetraits备忘
  18. January 22nd, 2018 Week 04th Monday
  19. CMake系列之四:多个源文件-多个目录
  20. node.js初识01

热门文章

  1. LWIP轻量级TCPIP协议栈的移植
  2. JSP页面乱码全解析
  3. EntityFramework:值语义的实体如何修改?
  4. 自定义ListView adapter适配器
  5. SharePoint 2013 App 示例之图片墙
  6. WPF性能调试系列 – Ants Performance Profiler
  7. 11.线程通信CountDownLatch
  8. android:Layout_weight的深刻理解
  9. 9个实用的Javascript代码高亮脚本
  10. java学习笔记1--开发环境平台总结