zoukankan      html  css  js  c++  java
  • JS 网页打印 页边距 页眉页脚

    以下示例代码本人是在IE6下进行的

    页面中的代码:

    <OBJECT id="WebBrowser1" height="0" width="0"
           classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" VIEWASTEXT>
    </OBJECT>

    相关JS:

    var hkey_root, hkey_path, hkey_key
    hkey_root = "HKEY_CURRENT_USER"
    hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
    // 设置 页眉 页脚 页边距
    function PagePrintSetup() {
        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, "");

            hkey_key = "margin_top";//注册表中的0.75对应于网页的19.05
            RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "0.15");

            //margin_bottom
            //margin_left
            //margin_right
        }
        catch (e) { }
    }

    function fn_winPrint() {
        document.all.tab_PrintButton.style.display = 'none';

        try {
         PagePrintSetup() ;
            document.all.WebBrowser1.execwb(6, 1);
        }
        catch (err) {
            window.print();
        }

        document.all.tab_PrintButton.style.display = 'block';

        return false;
    }

  • 相关阅读:
    Swift 类的使用class
    Swift 结构体struct
    Swift 枚举enum
    Swift 元组 Tuple
    python UI自动化截图对比
    取出yaml中的字符并转换为元祖
    python 使用pyinstaller对PY文件进行exe打包
    Jenkins 浏览器打开提示离线
    pywinauto 学习笔记-利用文本框输入操作键盘
    打开文件测试的测试点
  • 原文地址:https://www.cnblogs.com/freeliver54/p/1528449.html
Copyright © 2011-2022 走看看