• asp.net局部页面打印,以及如何去掉打印时自动保留的URL地址(页眉页脚)


    最近做了asp.net的局部打印,开始是想用报表的,可总是感觉不如自定义页面灵活。

    那么就来说说asp.net页面局部打印是如何实现的。

      <script type="text/javascript">
            var hkey_root, hkey_path, hkey_key;
            hkey_root = "HKEY_CURRENT_USER";
            hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
    //去掉页眉页脚的方法
    function pagesetup_null() { var hkey_root, hkey_path, hkey_key; hkey_root = "HKEY_CURRENT_USER" hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"; try { var RegWsh = new ActiveXObject("WScript.Shell"); hkey_key = "header"; RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, ""); hkey_key = "footer"; RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, ""); } catch (e) { } }
    //局部打印的方法 调用局部打印方法的时候调用去掉页眉页脚的方法即可
    function doPrint() { pagesetup_null(); bdhtml = window.document.body.innerHTML; sprnstr = "<!--startprint-->"; eprnstr = "<!--endprint-->"; prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17); prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr)); window.document.body.innerHTML = prnhtml; window.print(); } </script>
    //记得加这句代码 <OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0> </OBJECT>

    最后,在需要打印的页面部分用红色字体来标注即可,就可以实现页面局部打印以及去掉IE的页眉页脚设置 

    <!--startprint-->
    <div>
    <%=content%>
    </div>
    <!--endprint-->

     

  • 相关阅读:
    alpha冲刺1/4
    第二次作业
    第一次作业
    第一次个人作业
    第10组 Beta版本演示
    第10组 Beta冲刺(4/4)
    第10组 Beta冲刺(3/4)
    第10组 Beta冲刺(2/4)
    第10组 Beta冲刺(1/4)
    第10组 Alpha冲刺(4/4)
  • 原文地址:https://www.cnblogs.com/sulei4471/p/2814576.html
Copyright © 2020-2023  润新知