HTML操作打印機打印小票


<!DOCTYPE html> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>訂單打印</title> 
<script type="text/javascript">   
  function doPrint() {   
    bdhtml=window.document.body.innerHTML;   
    sprnstr="<!--startprint-->";   
    eprnstr="<!--endprint-->";   
    prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);   
    prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));   
    window.document.body.innerHTML=prnhtml;  
    window.print();   
}   
</script> 
</head> 
  
<body> 
<!-- <p>1不需要打印的地方</p> 
<p>2這里不要打印啊</p>  -->
<!--startprint--><!--注意要加上html里star和end的這兩個標記--> 
<div class="print_container">
    <h1>給顧客專用</h1>
    <span>**************************</span>
    <div class="section1">
        <h3>百度外賣</h3>
        <h3>在線支付預約</h3>
    </div>
    <span>**************************</span>
    <div class="section2">
        <label>期望送達時間:5678</label>
        <label>訂單備注:1111</label>
    </div>
    <span>**************************</span>
    <div class="section3">
        <label>訂單編號:567890</label>
        <label>下單時間:1111</label>
    </div>
    <span>**************************</span>
    <div class="section4">
        <div style="border-bottom: 1px solid #DADADA;">
            <table style="width: 100%;">
                <thead>
                    <tr>
                        <td width="60%">菜單名稱</td>
                        <td width="20%">數量</td>
                        <td width="20%">金額</td>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>米飯</td>
                        <td>2</td>
                        <td>28.00</td>
                    </tr>
                    <tr>
                        <td>米飯</td>
                        <td>2</td>
                        <td>28.00</td>
                    </tr>
                    <tr>
                        <td>米飯</td>
                        <td>2</td>
                        <td>28.00</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="other_fee">
            <div class="canh">
                <label class="left">餐盒費</label>
                <label class="right">0</label>
                <div class="clearfix"></div>
            </div>
            <div class="peis">
                <label class="left">配送費</label>
                <label class="right">0</label>
                <div class="clearfix"></div>
            </div>
            <div class="manj">
                <label class="left">立減優惠</label>
                <label class="right">0</label>
                <div class="clearfix"></div>
            </div>
        </div>
        <div class="total">
            <label class="left">總計</label>
            <label class="right">39</label>
            <div class="clearfix"></div>
        </div>
        <div style="text-align: right;">
            <label>顧客已付款</label>
        </div>
        <span>**************************</span>
    </div>
    <div class="section5">
        <label>姓名:小花</label>
        <label>地址:北京</label>
        <label>電話:67890</label>
    </div>    
    <span>**************************</span>
</div>
</div>
<!--endprint--> 
<button type="button" onclick="doPrint()">打印</button> 
<!-- <p>不打印的地方啊哈哈哈哈</p> 
<p>2</p>  -->
</body> 
</html>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM