zoukankan      html  css  js  c++  java
  • IE WebBrowser控件 打印

    最近发现在做打印时,需要去除打印页面的“页头”和“页眉”,在网上搜了下,结果搜出了一大堆都是用IE的控件,尝试了多种方法,还是觉得IE的WebBrowser控件好用,而且相对客户来说简单明了,但是他总是会跳出

    ,我刚刚尝试了,不管你是选择“是”或者“否”,在IE的浏览器下都能做到去除“页眉”和“页脚”,这个窗口的跳出给用户体验很不好,不知道你们的会不会,握在QQ邮箱里打印发现在IE下,居然不会弹出,究竟是如何屏蔽掉的呢,正在查找答案中。。。。。。。。会的同学发送709556550@qq.com
    但是用IE IE WebBrowser控件在火狐下是现实不了,在“猎豹”中能完美的清除,但是在“360急速"下网址和页码依然存在,没有办法自动除去,需要自己手工在设置中去除页眉和页脚。
     1 <script language="JavaScript">
     2     var hkey_root,hkey_path,hkey_key;
     3     hkey_root="HKEY_CURRENT_USER";
     4     hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
     5     //配置网页打印的页眉页脚为空
     6     function pagesetup_null(){   
     7         try{
     8             var RegWsh = new ActiveXObject("WScript.Shell");           
     9             hkey_key="header";           
    10             RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
    11             hkey_key="footer";
    12             RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
    13             //&b 第&p页/共&P页 &b
    14         }catch(e){}
    15     }
    16     //配置网页打印的页眉页脚为默认值
    17     function pagesetup_default(){
    18         try{
    19             var RegWsh = new ActiveXObject("WScript.Shell");
    20             hkey_key="header";
    21             RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P")
    22             hkey_key="footer";
    23             RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d");
    24         }catch(e){}
    25     }
    26 ...
    27 </script>

    示例:

     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     2 <html>
     3  <head>
     4   <title> New Document </title>
     5   <meta name="Generator" content="EditPlus">
     6   <meta name="Author" content="">
     7   <meta name="Keywords" content="">
     8   <meta name="Description" content="">
     9   <style media="print">
    10  URL, a{display:none;}
    11   
    12   </style>
    13   <script language="JavaScript">
    14     var hkey_root,hkey_path,hkey_key;
    15     hkey_root="HKEY_CURRENT_USER";
    16     hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
    17     //配置网页打印的页眉页脚为空
    18     function pagesetup_null(){   
    19         try{
    20             var RegWsh = new ActiveXObject("WScript.Shell");           
    21             hkey_key="header";           
    22             RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
    23             hkey_key="footer";
    24             RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
    25  
    26         }catch(e){}
    27     }
    28     function prints(){
    29         pagesetup_null();
    30         try{
    31             wb.execwb(6,1);
    32         }
    33         catch(e){
    34         pagesetup_null();
    35          window.print();
    36         }
    37     }
    38 
    39 </script>
    40  </head>
    41 
    42  <body>
    43 <OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>
    44 <a herf="#" onclick="prints();">打印本页</a>
    45 <div>5656</div>
    46  </body>
    47 </html>

    有什么好的办法可以留言下。。。

  • 相关阅读:
    2491 玉蟾宫
    1704 卡片游戏
    1020 孪生蜘蛛
    1215 迷宫
    3149 爱改名的小融 2
    1316 文化之旅 2012年NOIP全国联赛普及组
    1664 清凉冷水
    157. [USACO Nov07] 奶牛跨栏
    [SCOI2005]繁忙的都市
    【NOIP2014模拟赛No.1】我要的幸福
  • 原文地址:https://www.cnblogs.com/laiweidong/p/2864469.html
Copyright © 2011-2022 走看看