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

来源:互联网 发布:淘宝活动倒计时生成 编辑:程序博客网 时间:2024/05/22 16:08
  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>   
0 0