RT:IE下,右键网页,点击“打印”,能扑捉到这个事件并且执行一段js么?

解决方案 »

  1.   

    打印按钮:<INPUT  onclick="PRT3onclick()" type="button" value="打    印">js.
    function PRT3onclick()
    {
                            //a()要执行的js在此处调用
    WebBrowser.ExecWB(6,1);
    }
    <OBJECT id="WebBrowser" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" >
    </OBJECT>
      

  2.   

    错误提示:
    WebBrowser is not defined
    [Break on this error] WebBrowser.ExecWB(6,1); 
      

  3.   

    <script>//按钮事件
    var directPrint = function(){
    pagesetup_null();
    document.all.WebBrowser.ExecWB(6,6);
    }//设置网页打印的页眉页脚为空
    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){}
    } </script>
    </HEAD>
    <body> <input type=button name="打印" value="打印" style="font-size: 9pt; min-width:15px; min-height:10px"  onclick="directPrint()" id="Button1" />                         
    <OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0> 
                            </OBJECT>