Chinaunix首页 | 论坛 | 博客
  • 博客访问: 256297
  • 博文数量: 79
  • 博客积分: 3450
  • 博客等级: 中校
  • 技术积分: 875
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-18 13:12
文章分类

全部博文(79)

文章存档

2011年(1)

2010年(3)

2009年(19)

2008年(23)

2007年(15)

2006年(18)

我的朋友

分类: 系统运维

2009-09-02 09:08:46

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

页面中的代码:


       classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" VIEWASTEXT>

相关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;
}

阅读(2839) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~