_@zhng

导航

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*/
}

 

posted on 2013-02-18 12:51  _@zhng  阅读(267)  评论(0编辑  收藏  举报