zoukankan      html  css  js  c++  java
  • window.print

    1. 设置页眉-页脚

    (function () {
        var hkey_root,hkey_path,hkey_key; 
        hkey_root="HKEY_CURRENT_USER"; 
        hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"; 
        //配置网页打印的页眉页脚为空 
        function pagesetup_null(hc, fc){   
            try{ 
                var RegWsh = new ActiveXObject("WScript.Shell");           
                hkey_key="header";           
                RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,hc || ""); 
                hkey_key="footer"; 
                RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,fc || ""); 
                //&b 第&p页/共&P页 &b 
            }catch(e){} 
        } 
        //配置网页打印的页眉页脚为默认值 
        function pagesetup_default(){ 
            try{ 
                var RegWsh = new ActiveXObject("WScript.Shell"); 
                hkey_key="header"; 
                RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P") 
                hkey_key="footer"; 
                RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d"); 
            }catch(e){} 
        }
        window.pagesetup_null = pagesetup_null;
        window.pagesetup_default = pagesetup_default;
        
    })();

    2. 应用打印样式:

    <link href="path/to/print.css" rel="stylesheet" media="print"/>

    3. 不参与打印-设置css样式属性display值为none

    4. css media:

    media类型是CSS属性媒体类型,用于直接引入媒体的属性。
    其语法格式如下:
    @media screen | print | projection | braille | aural | tv | handheld | all
    参数说明
    screen:指计算机屏幕。
    print:指用于打印机的不透明介质。
    projection:指用于显示的项目。
    braille:盲文系统,指有触觉效果的印刷品。
    aural:指语音电子合成器。
    tv:电视类型的媒体。
    handheld:指手持式显示设备。
    all:用于所有媒体。

     5. 媒体查询:

    @media print {
    /*css regular comes here*/
    }
  • 相关阅读:
    编程路上有你们陪着值了
    我是屌丝程序猿,我为自己代言.
    JSON转换类
    深入理解requestAnimationFrame
    CentOS部署yapi
    前端三种路由方式
    yarn安装使用
    三大框架对比
    es6异步编程
    JS原型链
  • 原文地址:https://www.cnblogs.com/zhng/p/2915470.html
Copyright © 2011-2022 走看看