zoukankan      html  css  js  c++  java
  • 转贴:javsscript的打印

    <html>
    <head>
    <title>Print Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="javascript">
    function preview()
    {
    bdhtml=window.document.body.innerHTML;
    sprnstr="<!--startprint-->";
    eprnstr="<!--endprint-->";
    prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
    alert(prnhtml);
    prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
    alert(prnhtml);
    window.document.body.innerHTML=prnhtml;
    window.print();
    //prnform.htext.value=prnhtml;
    //prnform.submit();
    //alert(prnhtml);
    }
    </script>
    </head>

    <body bgcolor="#FFFFFF" text="#000000">
    辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣
    <center>本部分以上不被打印</center>
    <!--startprint-->
    <table width="84%" align="center" bgcolor="#0000FF" cellpadding="2" cellspacing="1">
      <tr bgcolor="#6699FF">
        <td>
          <div align="center">标题一</div>
        </td>
        <td>
          <div align="center">标题二</div>
        </td>
        <td>
          <div align="center">标题三</div>
        </td>
        <td>
          <div align="center">标题四</div>
        </td>
        <td>
          <div align="center">标题五</div>
        </td>
      </tr>
      <tr bgcolor="#6699FF">
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
    </table>
    <!--endprint-->
    <center>本部分以下不被打印</center>
    辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣辣
    <div align="center">
      <input type="button" name="print" value="预览并打印" onclick="preview()">
    </div>
    <style>
    @media print {
      .Noprn {display:none;}
    }
    </style>
    <p class="Noprn">不打印</p>
    <table id=datagrid><tr><td>打印</td></tr></table>
    <input class=Noprn type=button onclick="window.print()" value="print">
    </body>
    </html>
  • 相关阅读:
    从零开始整SpringBoot-工具与插件
    算法与数据结构学习笔记(目录)
    牛客小白月赛30(个人题解)
    Manjaro 上手使用简明教程
    C++函数:std::tie 详解
    Educational Codeforces Round 99 (Rated for Div. 2) (A ~ F)个人题解
    VS Code C++ 项目快速配置模板
    【字符串算法】字典树详解
    关于算法竞赛某些常见基础错误
    Teacher Ma专场
  • 原文地址:https://www.cnblogs.com/pojia/p/287770.html
Copyright © 2011-2022 走看看