如果没有这个方法,我想请问一下,平常如果要打印页面里的table,就是那种编码,姓名,性别,住址那种表格,平时是怎么打印出来的呢?

解决方案 »

  1.   

    <script language="javascript"> function PrintTable(Id){
    var mStr;
    mStr = window.document.body.innerHTML ;
    var mWindow = window;
    window.document.body.innerHTML =Id.innerHTML; 
    mWindow.print();
    window.document.body.innerHTML = mStr;
    }
    </script>
    <body>
    There will be not printed!
    <div ID="Table">
    <table border="1"  width="92%" height="24%">
    <TR>
    <TD>
    print
    </TD>
    <TD>
    print
    </TD>
    </TR>
    </TABLE>
    </DIV>
    <input type="submit" value="submit" onclick="return PrintTable(Table)">试试先!祝好运!
      

  2.   

    在beforeprint里面把你不打印的都隐藏掉!在afterprint里面再恢复!
      

  3.   

    flyycyu(fly) 说的beforeprint和afterprint的方法小弟未曾听过,哪位高手知道,能否给点代码一看?
      

  4.   

    用<%out.println("<script>alert('window.print()');</script>") ;%>这个方法可以打印吗?
    为什么我的就只弹出一个消息框,写着"window.print()"?
      

  5.   

    你的这段代码本来就是要弹出一个消息框。
    这是以前用vbscript写的东西,你参考一下。<script language=vbscript>
      sub window_onbeforeprint()
    tbfy.style.display="none"
    end sub sub window_onafterprint()
    tbfy.style.display="inline"
    end sub sub mydy()
    on error resume next
    if form1.setpage.value="true" then
    myprint.execwb 6,6
    else
    window.alert "请纵向插入A4纸张"
    myprint.execwb 6,6
    form1.setpage.value="true"
    end if

    end sub
    </script>
    把你不想打印的东西放到id 为tbfy 代码里面。
    例如:<table border="0" cellpadding="0" cellspacing="0" style="margin-left:0;BORDER-COLLAPSE: collapse" bordercolor="#111111" width="681" id="tbfy" height="28">                  
     <tr>        
     <td width="679"><p align=center> <input type="button" value="  打印  " name="B1" onclick="mydy()">  <input type="button" value="  关闭  " name="B2" onclick="vbscript:window.close "> </p>       
     </td>      
     </tr>      
      </table>