用另外一个打印的CSS
一个HTML可以用多个CSS的
先是用一个,打印用一个就行了

解决方案 »

  1.   

    给你一个:
    <script>
    window.onbeforeprint = new Function("document.all.pr.style.display='none'");
    window.onafterprint = new Function("document.all.pr.style.display=''");
    </script>JSP文件中
    out.println("<input type=button value=打印查询结果 
    onclick='self.print()' id='pr'>");
      

  2.   

    js
    <!--
     function printewindow()
    {
    var win2=window.open("","report","width=800,height=460,menubar=no,scrollbars,toolbar=0,left=0,top=0");
    win2.document.writeln("<html><head>");
    win2.document.writeln("<link rel='stylesheet' href='../font.css' type='text/css'>");
    win2.document.writeln("<style TYPE='text/css'>");
    win2.document.writeln("SPAN {font: 9pt 宋体}");
    win2.document.writeln("</style>");
    win2.document.writeln("<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>");
    win2.document.writeln("<title>报表</title></head><body>");
    win2.document.writeln(document.all("report").outerHTML);
    win2.document.writeln("<span id=prin><INPUT onclick='window.print();' type=button  value=打印本页> </span>");
    win2.document.writeln("<BR>");
    win2.document.writeln("<BR>");
    win2.document.writeln("</body></html>");
    win2.document.close();
    win2.focus();
    }
    //-->/////////////////
    jsp
    <table id=report width="700">
    ...你要打印的东西
    </table><INPUT onclick="return printewindow();" type=button value=打开打印窗口>
    <script language="JavaScript" src="../printdw.js"></script>
      

  3.   

    对了,在打印之前prin.style.display = 'none';
    prin.style.visibility = 'hidden';
    就去了那个打印按钮