js javascript js控制分页打印,打印分页

Html代码  收藏代码

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"  

  2.     pageEncoding="UTF-8"%>  

  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  

  4. <HTML>  

  5. <HEAD>  

  6. <TITLE>javascript打印-打印页面设置-打印预览代码</TITLE>   

  7. <META http-equiv=Content-Type content="text/html; charset=gb2312" />   

  8. <style media=print>   

  9. .Noprint{display:none;}   

  10. .PageNext{page-break-after: always;}   

  11. </style>  

  12. <SCRIPT language=javascript>   

  13.   function printsetup(){   

  14.   // 打印页面设置   

  15.   wb.execwb(8,1);   

  16.   }   

  17.   function printpreview(){   

  18.   // 打印页面预览     

  19.   wb.execwb(7,1);   

  20.   }   

  21.   function printit()   

  22.   {   

  23.   if (confirm('确定打印吗?')) {   

  24.   wb.execwb(6,6)   

  25.   }   

  26.   }   

  27. </SCRIPT>  

  28.   

  29. </HEAD>   

  30. <BODY>  

  31.   

  32. <DIV align=center>   

  33. <OBJECT id=wb height=0 width=0   

  34. classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 name=wb></OBJECT>   

  35. <INPUT onclick=javascript:printit() type=button value=打印 name=button_print />   

  36. <INPUT onclick=javascript:printsetup(); type=button value=打印页面设置 name=button_setup />   

  37. <INPUT onclick=javascript:printpreview(); type=button value=打印预览 name=button_show />   

  38. </DIV>   

  39. 111</br>   

  40. 111</br>   

  41. 111</br>   

  42. <div class="PageNext"></div>  

  43. 222</br>   

  44. 222</br>   

  45. 222</br>   

  46. <div class="PageNext"></div>  

  47. 333</br>   

  48. 333</br>   

  49. 333</br>   

  50. <div class="PageNext"></div>  

  51. 444</br>   

  52. 444</br>   

  53. 444</br>   

  54. <div class="PageNext"></div>  

  55. 555</br>   

  56. 555</br>   

  57. 555</br>   

  58. </BODY>   

  59. </HTML>  



Html代码  收藏代码

  1. <html>  

  2. <title>JS 分页批量打印解决方案(只支持IE)</title>  

  3. <script language="javascript">           

  4.  function printWithAlert() {         

  5.  document.all.WebBrowser.ExecWB(6,1);      

  6.  }       

  7.  function printWithoutAlert() {        

  8.    document.all.WebBrowser.ExecWB(6,6);       

  9.  }     

  10.  function printSetup() {         

  11.  document.all.WebBrowser.ExecWB(8,1);       

  12.  }      

  13.  function printPrieview() {         

  14.  document.all.WebBrowser.ExecWB(7,1);       

  15.  }       

  16. function printImmediately() {         

  17. document.all.WebBrowser.ExecWB(6,6);        

  18.  window.close();       

  19.  }        

  20. </script>  

  21. <OBJECT  id=WebBrowser  classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 style="display:none">  

  22. </OBJECT>  

  23. </noscript>  

  24. <style media=print>   

  25. .Noprint{display:none;}  .PageNext{page-break-after: always;}   

  26. </style>  

  27. <table align="center" class=NOPRINT>  

  28.   <tr>  

  29.     <td align="center"><BUTTON title=打印 onclick=printWithAlert()>打印</BUTTON>  

  30.       <BUTTON title=直接打印 onclick=printWithoutAlert()>直接打印</BUTTON>  

  31.       <input type=button value="打印设置" onClick="printSetup()" >  

  32.       <button onclick ='printPrieview()' title='打印预览...' >打印预览</button></td>  

  33.   </tr>  

  34. </table>  

  35. <div  class=NOPRINT> 以下为打印区:<br>  

  36. </div>  

  37. <hr size=1 noshadow color=black  class=NOPRINT >  

  38. <table class="PageNext" >  

  39.   <tr>  

  40.     <td colspan=2>  

  41.  第一页的内容  

  42.  11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111  

  43.     </td>  

  44.   </tr>  

  45. </table>  

  46. <hr size=1 noshadow color=black  class=NOPRINT >  

  47. <div class="PageNext">  

  48. 第二页内容  

  49.  11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111  

  50. </div>  

  51. <hr size=1 noshadow color=black  class=NOPRINT >  

  52. 第三页内容  

  53. </html>   



黑色头发:http://heisetoufa.iteye.com/

转载于:https://my.oschina.net/liangzhenghui/blog/219543

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值