• 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>
  • 相关阅读:
    va_start/va_arg/va_end原理与使用
    一民工在火车上的遭遇(笑过后全是泪水)
    Introduce to ArcSDE
    浅谈优化空间数据库的几种方案
    ArcSDE安装全攻略(来源:GIS空间站 作者:陈元琳)
    arcsde sqlserver数据库的移植
    arcims开发经验总结(4) (arcIMS 客户端 连接器的选择)
    ArcSDE 8.1中空间数据的备份与恢复
    安装ArcSDE9 For Sqlserver的过程
    arcims开发经验总结(3) (杂谈1)
  • 原文地址:https://www.cnblogs.com/xiaonangua/p/13435544.html
Copyright © 2020-2023  润新知