打印網(wǎng)頁

<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>打印</title>
<meta name="decorator" content="list"/>
<script type="text/javascript">
    $(document).ready(function() {
        $("#btnPrint").on("click",function() {
            doPrint();
        })
        function doPrint() {   
            bdhtml=window.document.body.innerHTML;   
            sprnstr="<!--startprint-->";   //開始打印標(biāo)識(shí)字符
            eprnstr="<!--endprint-->";   //結(jié)束打印標(biāo)識(shí)字符
            prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);  //從開始打印標(biāo)識(shí)之后的內(nèi)容(“標(biāo)識(shí)符是17位”) 
            prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));   //截取開始標(biāo)識(shí)和結(jié)束標(biāo)識(shí)之間的內(nèi)容
            window.document.body.innerHTML=prnhtml;  //把需要打印的指定內(nèi)容賦給body.innerHTML
            window.print();//打印 
            window.document.body.innerHTML=bdhtml;//重新給頁面內(nèi)容賦值; (可省略) 
        }   
    });
</script>
</head>
<body class="fixed-navbar fixed-sidebar">
  <!--startprint-->
  <div class="dataTables_wrapper form-inline dt-bootstrap no-footer">
   <div class="row">
    <div class="col-sm-12">
      <table id="dataList" class="table table-striped table-bordered table-hover table_fixed dataTable no-footer">
       <thead>
        <tr>
             <th style="width:35px">姓名</th>
             <th style="width:35px">**</th>
             <th style="width:35px">**</th>
        </tr>
       </thead>
        <tbody>
         <c:forEach items="${jsonList}" var="item">
          <tr>
              <td style="width:35px">姓名</td >
              <td style="width:35px">**</td >
              <td style="width:35px">**</td >
      </tr> 
         </c:forEach>
        </tbody>
     </table>
    </div>
   </div>
  </div>
  ${page}
  <!--endprint--> 
  <!--列表結(jié)束-->
</body>
</html>
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容