yangpanwww 发表于 2013-1-29 08:52:08

WebBrowser 打印

WebBrowser 的打印
 
可以直接下载 打印示例 查看
 
html代码 + 样式:
<style media="print">    .Noprint{display:none;}<!--用本样式在打印时隐藏非打印项目-->    .PageNext{page-break-after: always;} <!--控制分页--></style><object id="WebBrowser"width="0"height="0"classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>   <center class="Noprint" ><input type="button"value="打印预览" ><input type="button"value="打 印"    ><input type="button"value="页面设置" ><input type="button"value="恢复页码">    <input type="button"value="关 闭"    > </center> 
js 代码:
<script type="text/javascript">var HKEY_Root,HKEY_Path,HKEY_Key; HKEY_Root="HKEY_CURRENT_USER"; HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"; //设置网页打印的页眉页脚为空 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,"");   }catch(e){    //报错了}} //设置网页打印的页眉页脚为默认值 functionPageSetup_Default(){    try{   var Wsh=new ActiveXObject("WScript.Shell");HKEY_Key="header";   //Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&w&b页码,&p/&P");   //去除&w 去除标题只打印页码Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&b页码,&p/&P");HKEY_Key="footer";   //Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&u&b&d");   //去除&u 去除url只打印时间Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&b&d"); }catch(e){ //报错了 } }</script> 
 
   如果你想让界面的 哪些地方打印的时候 不显示 则使用 class = "Noprint" 这个样式,分页就使用 PageNext
页: [1]
查看完整版本: WebBrowser 打印