H5启用打印机打印参数设置A4

简介: H5启用打印机打印参数设置A4
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
    <title>学员满意度测评表</title>
 
    <!-- Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
 
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <style>
    .a4-endwise{
      width: 1075px;
      height: 1567px;
      border: 1px #000 solid;
      overflow: hidden;
      padding: 0;
      word-break:break-all;
    }
    .a4-broadwise{
      width: 1569px;
      height: 1073px;
      border: 1px #000 solid;
      overflow: hidden;
      padding: 0;
      word-break:break-all;
    }
    .print{
      position: fixed;
      top: 1%;
      right: 10%;
    }
  </style>
  <body>
<a class="print" href="javascript:;" onclick="preview();">打印</a>
<!--startprint-->
    <div class="container a4-endwise" id="test">
 
    </div>
    <div class="container a4-endwise">
 
    </div>
    <div class="container a4-endwise">
 
    </div>
<!--endprint-->
 
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script>
        /**
         * [打印]
         * @return {[type]} [description]
         */
        function preview()
        {
            bdhtml=window.document.body.innerHTML;//获取当前页的html代码
            sprnstr="<!--startprint-->";//设置打印开始区域
            eprnstr="<!--endprint-->";//设置打印结束区域
            prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html
            prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
            window.document.body.innerHTML=prnhtml;
            window.print();
            window.document.body.innerHTML=bdhtml;
        }
    </script>
 
  </body>
</html>

 


相关实践学习
Serverless极速搭建Hexo博客
本场景介绍如何使用阿里云函数计算服务命令行工具快速搭建一个Hexo博客。
相关文章
|
安全 Windows
Windows 无法连接打印机,请检查打印机名并重试。如果这是网络打印机,请确保打印机已打开,并且打印机地址正确。报错代码:0x00000709
Windows 无法连接打印机,请检查打印机名并重试。如果这是网络打印机,请确保打印机已打开,并且打印机地址正确。报错代码:0x00000709
Windows 无法连接打印机,请检查打印机名并重试。如果这是网络打印机,请确保打印机已打开,并且打印机地址正确。报错代码:0x00000709
|
Linux
LINUX设置终端窗口显示内容的滚动缓冲行数
LINUX设置终端窗口显示内容的滚动缓冲行数
318 0
LINUX设置终端窗口显示内容的滚动缓冲行数
Win2000下打印设定
Win2000下打印设定
528 0