首页 > 编程语言 > 详细

【转】javascript打印设置

时间:2014-09-22 13:33:23      阅读:242      评论:0      收藏:0      [点我收藏+]

页面中的代码:
<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;
}

【转】javascript打印设置

原文:http://www.cnblogs.com/lizhancheng/p/3985780.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!