zoukankan      html  css  js  c++  java
  • JavaScript打印页面

    打印整个页面,去除打印按钮

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title></title>
        <style type="text/css">
            * {
                margin: 0px;
                padding: 0px;
            }
      </style>
    </head>
    <body ondragstart="return false">
        <div class="zhengshucontent">
            <img class="zsbg" src="~/Content/JobInjuryCertManager/Image/zhengshubg.png">
            <div class="bainhao">@(certInfo != null && certInfo.Id > 0 ? certInfo.CertNumber : "")</div>
            <div class="photo">
                <img src="@(certInfo != null && certInfo.Id > 0 ? certInfo.PhotoUrl : "")">
            </div>
            <div class="center">
    
                <div class="name">@(certInfo != null && certInfo.Id > 0 ? certInfo.Name : "")</div>
                <div class="idnumber">@(certInfo != null && certInfo.Id > 0 ? certInfo.PersonalId : "")</div>
    
            </div>
            <div class="bottombox">
                <div class="jigou">@(certInfo != null && certInfo.Id > 0 ? certInfo.DepartmentName : "")</div>
                <div class="yearmonnthday"><span>@(certInfo != null && certInfo.Id > 0 ? certInfo.CreateTime.ToString("yyyy") : "")</span><span>@(certInfo != null && certInfo.Id > 0 ? certInfo.CreateTime.ToString("MM") : "")</span><span>@(certInfo != null && certInfo.Id > 0 ? certInfo.CreateTime.ToString("dd") : "")</span></div>
            </div>
            <div class="erweima">
                <img src="@(certInfo != null && certInfo.Id > 0 ? certInfo.ErWeiMa : "")">
            </div>
        </div>
        <!--endprint-->
        <button onclick="printCert()">打印</button>
    </body>
    </html>
    
    <script>
    function printCert() {
            var eprnstr = "<!--endprint-->";
            var oldstr = document.body.innerHTML;
            var newstr = oldstr.substring(0, oldstr.indexOf(eprnstr));
    
            document.body.innerHTML = newstr + "</body></html>";
            window.print();
            document.body.innerHTML = "";
            document.body.innerHTML = oldstr;
        }
    </script>
  • 相关阅读:
    子网掩码的作用与IP网段的划分
    DHCP服务器
    Anaconda安装、更新第三方包
    time模块的使用
    TensorFlow安装
    机器学习-线性回归
    机器学习
    Pyhton-类(2)
    python-类(1)
    Python-函数
  • 原文地址:https://www.cnblogs.com/xiaonangua/p/13435544.html
Copyright © 2011-2022 走看看