window.print()方法设置分页

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">     
<style media=print>   //主要分页作用
.PageNext{page-break-after: always;}   
</style>   
 
<style>
.pd_20 {
    padding: 20px 15px 5px 20px!important;
}

.lh_36 {
    line-height: 36px !important;
}

.tr {
    text-align: right !important;
}

.mt_10 {
    margin-top: 10px !important;
}

.mt60 {
    margin-top: 30px !important;
}

.dib {
    display: inline-block !important;
}

.bb {
    border-bottom: 1px solid #333 !important;
}

.ve_t {
    vertical-align: top;
}

.t_indent {
    text-indent: 20px !important;
}

.declare_table {
    width: 710px;
    margin: 0 auto;
    font-size: 14px;
    color: #333;
}

.declare_table table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    word-wrap: break-word;
    word-break: break-all;
    border: none;
}

.declare_table .input input {
    width: 100%;
    height: 100%;
    font-size: 14px;
    text-indent: 15px;
    color: #333;
    border: none;
}

.declare_table .input input:focus {
    outline: none;
}

.declare_table table .w_auto {
    width: auto;
    font-size: 14px;
    font-family:"宋体"
}

.declare_table .textarea textarea {
    width: 100%;
    font-size: 14px;
    font-family:"宋体";
    text-indent: 5px;
    color: #333;
    padding: 0;
    border: none;
    resize: none;
}

.declare_table .textarea textarea:focus {
    outline: none;
}

.declare_table table thead tr {
    height: 40px;
}

.declare_table table tbody tr {
    text-align: left;
    height: 34px;
    border: 1px solid #333;
}

.declare_table table tbody tr td {
    padding: 2px 5px;
    border: 1px solid #333;
}

.declare_table .table_note {
    margin-top: 10px;
}

.declare_table .table_note p {
    margin: 0px;
}

.declare_table .checkbox_item {
    margin-top: 10px;
}

body{
    font-family:"宋体"
}

</style>  
 
</head>   
 
<body >   
    <div class="declare_table"> 
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0">   
            <thead>
                <tr style="width:100%">
                    <th colspan="4" class="input" style="text-align:center; font-size:30px;margin-top:10px;">
                        <div>计划书</div>
                        <div style="margin-left: 460px; font-size:16px;margin-top:10px;margin-bottom: 5px">日期:<span >2019年5月</span></div>
                    </th>
                </tr>
            </thead>
                
            <tbody style="font-size: 14px">
                <tr >

                    <td style="margin-left: 30px">姓名:</td>
                    <td class="input" ><span   style="font-size: 12px;font-family:'宋体'">天飞侠</span>
                    </td>
                  <td style="margin-left: 30px">年龄:</td>
                    <td class="input" ><span   style="font-size: 12px;font-family:'宋体'">20</span>
                    </td>
                </tr>
                <tr>
                    <td style="margin-left: 30px">出生日期:</td>
                   <td class="input" ><span   style="font-size: 12px;font-family:'宋体'">2035年1月1日</span>
                    </td>
                    <td style="margin-left: 30px">性别:</td>
                   <td class="input" ><span   style="font-size: 12px;font-family:'宋体'">男</span>
                    </td>
                </tr>

            
                <tr style="padding-top: 5px">
             <td colspan="2" >
                        <div>自己审批意见:</div>
                        <div class="textarea" style="margin-top: 10px">
                            <textarea rows="6" id="audit10-content" style="text-align: center;"></textarea>
                        </div>
                        <div class="input" >
                            签名及日期:<input type="text" class="w_auto" id="audit10" style="margin-top: -10px;width:250px">
                        </div>
                    </td>
                    <td colspan="2">
                        <div>领导甲意见:</div>
                        <div class="textarea" style="margin-top: 10px">
                            <textarea  rows="6"  id="audit11-content" style="text-align: center;"></textarea>
                        </div>
                        <div class="input">
                            签名及日期:<input type="text" class="w_auto" id="audit11" style="margin-top: -10px;width:250px">
                        </div>
                    </td>  
                </tr>
                <tr>

                             

                    <td colspan="2">
                        <div>学校意见(盖章):</div>
                        <div class="textarea" style="margin-top: 10px">
                            <textarea rows="6" id="audit4-content" style="text-align: center;" ></textarea>
                        </div>
                        <div class="input" >
                            签名及日期:<input type="text" class="w_auto" id="audit4" style="margin-top: -10px;width:250px">
                        </div>
                    </td>
                    <td colspan="2">
                        <div>学院意见:</div>
                        <div class="textarea" style="margin-top: 10px">
                            <textarea  rows="6"  id="audit5-content" style="text-align: center;"></textarea>
                        </div>
                        <div class="input">
                            签名及日期:<input type="text" class="w_auto" id="audit5" style="margin-top: -10px;width:250px">
                        </div>
                    </td>
                </tr> 
        </tbody>   
</table>   

  <!--开始分页--><hr align="center" width="90%" size="1" noshade  >   
<div class="PageNext"></div>   
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" > 
    <tbody style="font-size: 14px">
                <tr>
                    <td colspan="4">
                        <div>省发改委意见:</div>
                        <div class="textarea" style="margin-top: 10px">
                            <textarea rows="6" id="audit8-content"></textarea>
                        </div>
                        <div class="input tr" style="margin-bottom: 10px">
                            签名及日期:<input type="text" class="w_auto" id="audit8" style="margin-top: -10px;width:250px">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <div>国家发改委意见:</div>
                        <div class="textarea" style="margin-top: 10px">
                            <textarea rows="6" id="audit9-content"></textarea>
                        </div>
                        <div class="input tr" style="margin-bottom: 10px">
                            签名及日期:<input type="text" class="w_auto" id="audit9" style="margin-top: -10px;width:250px">
                        </div>
                    </td>
                </tr>
            </tbody>  
</table>  
        <div class="table_note">
            <p>注:本表双面印制,一式叁份,属于个人机密。</p>
        </div>   

    </div>
</body> 

<script type="text/javascript">

//设置自动弹出打印框
window.print();

//检验IE浏览器

if (!!window.ActiveXObject || "ActiveXObject" in window){setTimeout(shotBoy,50000) }else{    shotBoy()}             
function shotBoy(){
    window.addEventListener('afterprint',function() {
      window.close();
    })
}  

</script>  
</html>


版权声明:本文为weixin_41991473原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。