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>

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM