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

Html代碼  收藏代碼javascript

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

  2.     pageEncoding="UTF-8"%>  java

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

  4. <HTML>  spa

  5. <HEAD>  htm

  6. <TITLE>javascript打印-打印頁面設置-打印預覽代碼</TITLE>   ip

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

  8. <style media=print>   input

  9. .Noprint{display:none;}   it

  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/

相關文章
相關標籤/搜索