• 网页打印


    //设置网页打印的页眉页脚为空
    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 print() {
                //获取要打印的dom
                var js_Element = document.getElementById("tb_Main");
                //bdhtml = window.document.body.innerHTML;
                //sprnstr = "<!--startprint-->";
                //eprnstr = "<!--endprint-->";
                //prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
                //prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
                var newwin = window.open("tmp.html", "", "height=768,width=1024");
                newwin.document.open("text/html", "replace");
                newwin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
                newwin.document.write('<html xmlns="http://www.w3.org/1999/xhtml">');
                newwin.document.write('<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
                newwin.document.write('<link id="print" href="/css/print.css" rel="stylesheet" type="text/css" />');
                newwin.document.write('<title></title></head><body>');
                newwin.document.write(js_Element.outerHTML);
                //newwin.document.body.innerHTML = prnhtml;
                newwin.document.write('</body></html>');
                newwin.document.close();
                newwin.document.getElementById("print").href = "/css/print.css";
                //打印内容调整...
                pagesetup_Null(); //设置网页打印的页眉页脚为空
                newwin.print();
                newwin.close();
            }
  • 相关阅读:
    球员岁月齐祖辉煌,执教生涯尤胜当年
    UVM序列篇之一:新手上路
    *2-3-7-加入field_automation机制
    2.3.6-加入scoreboard
    *2_3_5_加入reference model
    *2.3.4_封装成agent
    *2.3.3-加入monitor
    android的wake_lock介绍
    linux常用命令一些解释
    linux wc命令的作用。
  • 原文地址:https://www.cnblogs.com/duhongyu216/p/3501689.html
Copyright © 2020-2023  润新知