本人是用js写,代码如下:
function PageSetup_Null() {
    try {
        var Wsh = new ActiveXObject("WScript.Shell");
        HKEY_Key = "header";
        //设置页眉(为空)   
        Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "");
        HKEY_Key = "footer";
        //设置页脚(为空)   
        Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "");
        HKEY_Key = "margin_bottom";
        //设置下页边距(0)   
        Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
        HKEY_Key = "margin_left";
        //设置左页边距(0)   
        Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
        HKEY_Key = "margin_right";
        //设置右页边距(0)   
        Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
        HKEY_Key = "margin_top";
        //设置上页边距(8)   
        Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "8");
    } catch(e) {
        alert("不允许ActiveX控件");
    }
}
   ActiveXObject("WScript.Shell");这个对象无效,网上的方法我都试过了,都无效JavaScriptactivex

解决方案 »

  1.   

    ActiveXObject ,只在IE下运行,并开放安全限制
      

  2.   

    web打印自定义 是个比较头疼的事。
    网上一些 打印控件 也是基于ActiveX
    所以 浏览器兼容性很是问题
      

  3.   

     
    如果 开放安全限制了就不会提示 这个对象无效 了
    你的 HKEY_Root ,  HKEY_Path  有设置过值??
     
      

  4.   

     
    如果 开放安全限制了就不会提示 这个对象无效 了
    你的 HKEY_Root ,  HKEY_Path  有设置过值??
     设置过了
      

  5.   

    var HKEY_Root,HKEY_Path,HKEY_Key;   
    HKEY_Root="HKEY_CURRENT_USER";   
    HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
    var head,foot,top,bottom,left,right;   
      
    //取得页面打印设置的原参数数据function PageSetup_temp() {
        try {
            var Wsh = new ActiveXObject("WScript.Shell");
            HKEY_Key = "header";
            //取得页眉默认值   
            head = Wsh.RegRead(HKEY_Root + HKEY_Path + HKEY_Key);
            HKEY_Key = "footer";
            //取得页脚默认值   
            foot = Wsh.RegRead(HKEY_Root + HKEY_Path + HKEY_Key);
            HKEY_Key = "margin_bottom";
            //取得下页边距   
            bottom = Wsh.RegRead(HKEY_Root + HKEY_Path + HKEY_Key);
            HKEY_Key = "margin_left";
            //取得左页边距   
            left = Wsh.RegRead(HKEY_Root + HKEY_Path + HKEY_Key);
            HKEY_Key = "margin_right";
            //取得右页边距   
            right = Wsh.RegRead(HKEY_Root + HKEY_Path + HKEY_Key);
            HKEY_Key = "margin_top";
            //取得上页边距   
            top = Wsh.RegRead(HKEY_Root + HKEY_Path + HKEY_Key);
        } catch(e) {
            alert("不允许ActiveX控件");
        }
    }