zoukankan      html  css  js  c++  java
  • javascript调用ie打印机

    window.print()方法调用ie打印,但打印出来有页码和路径,所以需要用脚本修改注册表:

    var HKEY_Root,HKEY_Path,HKEY_Key;
        HKEY_Root = "HKEY_CURRENT_USER\\";
        HKEY_Path="Software\\Microsoft\\Internet Explorer\\PageSetup\\";
        window.onload=PageSetup_Null();
        window.unonload=PageSetup_Reset();
      function PageSetup_Null(){
      try{
       var Wsh = new ActiveXObject("WScript.Shell");
       HKEY_Key = "header";
       //Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key);
       Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
       HKEY_Key = "footer";
       //Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key);
       Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
       }
       catch(e){
       }
      }
      function PageSetup_Reset(){
      try{
       var Wsh = new ActiveXObject("WScript.Shell");
       HKEY_Key = "header";
       Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&w&b页码,&p/&P");
       HKEY_Key = "footer";
       Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&u&b&d");
       }
       catch(e){
         
       }
      }

    这样就行了,但要隐藏页面中的某些内容使之显示出来而不打印出来:导入两个样式表

    <link rel="stylesheet" href="/websys/bz/css/common.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="/websys/bz/css/print.css" type="text/css" media="print" />

    两个css:

    common.css内容如下:

    *.dd{
    display:block;
    }

    print.css内容如下:

    *.dd{
    display:none;
    }
    在我们需要隐藏的地方写上class='dd'就行了。

  • 相关阅读:
    MySQL 重要参数 innodb_flush_log_at_trx_commit 和 sync_binlog
    mysql物理日志和逻辑日志_mysql物理日志redo log和逻辑日志 binlog
    Navicat Premium for Mac 破解版
    qps是什么
    如何实现扫码登录功能?
    goland debug
    [Golang] 初探之 sync.Once
    go语言:sync.Once的用法
    Golang进程权限调度包runtime三大函数Gosched,Goexit,GOMaXPROCS
    Go unsafe 包之内存布局
  • 原文地址:https://www.cnblogs.com/zack/p/1434456.html
Copyright © 2011-2022 走看看