網頁列印

來源:互聯網
上載者:User

標籤:button   log   cti   min   int   char   地址   隱藏   page   

一、普通列印(整頁打)

調用原生javascript方法——window.print()

 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>整頁列印</title> 6 <script> 7 function printpage(){ 8     window.print(); //調用此方法,列印整個頁面 9 }10 </script>11 </head>12 <body>13 14 <input type="button" value="列印此頁面" onclick="printpage()" />15 16 </body>17 </html>

 

 

二、局部列印

jQuery外掛程式jquery.PrintArea.js可實現列印頁面某地區功能

:http://plugins.jquery.com/PrintArea/

 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4     <meta charset="UTF-8"> 5     <title>利用 jquery.PrintArea.js 外掛程式實現局部列印</title> 6     <script type="text/javascript" src="jquery-1.7.1.min.js"></script>  7     <script type="text/javascript" src="jquery.PrintArea.js"></script>  8     <script> 9     $(function(){10         $("#print").click(function(){ 11             $(".my_show").printArea(); // 調用此方法實現局部列印12         }); 13     });14     </script>15 </head>16 <body>17     <div class="my_show"> 18         這個是列印時顯示的。。。 19     </div> 20     <div class="my_hidden"> 21         這個是列印時隱藏的。。。 22     </div> 23     <input type="button" id="print"/> 24 </body>25 </html>

 

網頁列印

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.