请教各位高手这个页面里有一个css属性 <style >  
@media   print{  BODY   {display:none}}   /* 防打印 */
</style>  作用是,使页面不能被打印。现在我要加一个按钮,只有在点击的时候才能够打印页面。
现在的主要问题是不知道这段js应该怎么写,才能够修改 @media   print 里的打印属性
页面的代码如下<style >  
@media   print{  BODY   {display:none}}   /* 防打印 */
</style>  <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0> 
</OBJECT><input type="button"  value="打印" onclick ="document.body.style.cssText='color:red';wb.execwb(6,1)">以上代码只能修改body里的样式 而对@media   print 里的属性无效请教各位高手达人啊,小弟谢谢了~

解决方案 »

  1.   

    这样试下.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <style type="text/css" media="print" id="style1" >  
    BODY{display:none}  /* 防打印 */ 
    </style>
    </head><body>
    打印内容...
    ...<input type="button" value="打印" onclick="allowPrint();" />
    <script type="text/javascript">
    function allowPrint(){
    var style = document.getElementById('style1');
    style.media = "none";
    window.print();
    }
    </script>
    </body>
    </html>
      

  2.   

    <input type="button"  value="打印" onclick ="document.body.style.cssText='display:block';wb.execwb(6,1)"> 
      

  3.   

    <style>
    @media screen {
    .input1 {display:none}
    .input2 {}
    }
      
        
    @media print {
    .input1 {}
    .input2 {display:none}
    }
    </style>  
        
      ……   
      <body>   
      <input class="input1"  type="submit"   value="打印"   id=submit1   name=submit1 >   
      <input class="input2"  type="submit"   value="不打印,但可以看"   id=submit1   name=submit1 >   
      ……   
      </body>   
      

  4.   

    style type="text/css" media="print" id="style1" >  
    BODY{display:none}  /* 防打印 */ 
    </style>
    如果 这个样式中 还有 table 样式,那么 要是 执行 style.media = "none";
     之后 table 的样式怎么办呢 ?