<!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>