web print

2018-06-24 00:01:43来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>The HTML5 Herald</title>
  <meta name="description" content="The HTML5 Herald">
  <meta name="author" content="SitePoint">
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
  <meta name="description" content="Responsive HTML5 and CSS3 site templates designed by @ajlkn." />
  <meta name="keywords" content="html5, css3, responsive, site template, website template" />
  <meta name="apple-mobile-web-app-title" content="HTML5 UP" />
  <style type="text/css" media="screen">
  #divPrint
  {
      background-color:#ffffff;
      font-size:20px;
      }
#tab
 {
     height:100px;
     width:400px;
     border:5px solid #000000;
     }

      .style1
      {
          height: 50px;
          border:5px solid #000000;
      }
  </style>
<script type="text/javascript">
    function CallPrint(strid) {
        var prtContent = document.getElementById(strid);
        var WinPrint = window.open('', '', 'letf=0,top=0,width=850,height=800,toolbar=0,scrollbars=1,status=0');
        WinPrint.document.write('<html><head><title>Popup 涂聚文</title>') //自定义标题
        WinPrint.document.write('</head><body>');
        WinPrint.document.write('</body></html>');
        WinPrint.document.write(prtContent.innerHTML);
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();  //没有网址内容
    }
</script>  
</head>
<body>
 <form id="form1" runat="server">  
<input id="btnPrint" type="button" value="Print" runat="server"  onclick="javascript:CallPrint('divPrint')"/>
    <div id="divPrint">
    <table id="tab">
    <tr id="tcss">
    <td class="style1">Your controls </td>
    <td class="style1"> 打印的内容</td>
    </tr>
        <tr id="tcss">
    <td class="style1">涂聚文<br /></td>
    <td class="style1">天下为公</td>
    </tr>
    </table>
  

  
  
</div>
        </form>  
</body>
</html>

  

function print1()
{
if (navigator.appname == "microsoft internet explore")
{
var printcommand = '<object id="printcommandobject" width=0 height=0 classid="clsid:8856f961-340a-11d0-a96b-00c04fd705a2"></object>';
document.body.insertadjacenthtml('beforeend', printcommand);
 document.all.printcommandobject.execwb(6,-1);
printcommandobject.outerhtml = "";
}
else {
window.print();
}
}
</script>
 
<button onclick=print1()>Try it</button>
 
2-this is second code which i tried
 
<script>
function btn_print_onclick() {
  factory.printing.header = "This is MeadCo";
  factory.printing.footer = "Printing by ScriptX";
  factory.printing.portrait = false;
  factory.printing.leftMargin = 1.0;
  factory.printing.topMargin = 1.0;
  factory.printing.rightMargin = 1.0;
  factory.printing.bottomMargin = 1.0;
  factory.printing.Print(false);
}
</script>
 

</head>
<body>
   <button onclick="btn_print_onclick()">Print report</button>
</body>

  https://www.codeproject.com/questions/1013399/silent-print-from-client-side-ie

https://www.codeproject.com/articles/24089/create-activex-in-net-step-by-step

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:vue插件编写与实战

下一篇:webstorm+nodejs环境中安装淘宝镜像