Home > Article > Web Front-end > Ask a question about using WebBrowser to print_html/css_WEB-ITnose
Using WebBrowser printing related, it was set that only a part of the page needs to be printed, so the style attribute media="print" was added. However, the table can be seen on the page, but the table cannot be seen in the print preview or printout. The code is as follows
<!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=utf-8" /> <title>测试</title> <style type="text/css"> .ttd { background-color: White; width: 120px; height: 50px; } .ttab { border: 0; width: 100%; cellpadding: 0; cellspacing: 1; background-color: #000000; } </style> <style type="text/css" media="print"> .ttd { background-color: White; width: 120px; height: 50px; } .ttab { border: 0; width: 100%; cellpadding: 0; cellspacing: 1; background-color: #000000; } .noprint { display: none; } </style> <script language="javascript"> function printsetup() { // 打印页面设置 wb.execwb(8, 1); } function printpreview() { // 打印页面预览 wb.execwb(7, 1); } function printit() { if (confirm('确定打印吗?')) { wb.ExecWB(6, 1) //wb.execwb(1,1)//打开 //wb.ExecWB(2,1);//关闭现在所有的IE窗口,并打开一个新窗口 //wb.ExecWB(4,1)//;保存网页 //wb.ExecWB(6,1)//打印 //wb.ExecWB(7,1)//打印预览 //wb.ExecWB(8,1)//打印页面设置 //wb.ExecWB(10,1)//查看页面属性 //wb.ExecWB(15,1)//好像是撤销,有待确认 //wb.ExecWB(17,1)//全选 //wb.ExecWB(22,1)//刷新 //wb.ExecWB(45,1)//关闭窗体无提示 } } </script></head><body> <div style="width: 640px; height: 20px; margin: 100px auto 0 auto; font-size: 12px; text-align: right;"> <input value="打印" type="button" onclick="printit()" /> <object classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" id="wb" name="wb" width="0"> </object> <input type="button" name="button_print" style="display: none;" value="打印本单据" onclick="javascript:printit()"> <input type="button" name="button_setup" value="打印页面设置" onclick="javascript:printsetup();"> <input type="button" name="button_show" value="打印预览" onclick="javascript:printpreview();"> <input type="button" name="button_fh" value="关闭" onclick="javascript:window.close();"> </div> <div style="width: 640px; height: 624px; margin: 20px auto;"> <table class="ttab"> <tr> <td class="ttd"> 型号:10010 </td> <td class="ttd"> <asp:label runat="server" id="lblModel"></asp:label> </td> <td class="ttd"> 长度:100cm </td> <td class="ttd"> <asp:label runat="server" id="lblLength"></asp:label> </td> <td class="ttd"> 额定电压:2200KV </td> <td class="ttd"> <asp:label runat="server" id="lblRatedVol"></asp:label> </td> <td class="ttd"> 出厂日期:2010-12-30 </td> <td class="ttd"> <asp:label runat="server" id="lblDlvDate"></asp:label> </td> </tr> </table> <p class="noprint"> 此区域打印不显示</p> <table> </table> </div></body></html>
Up yourself
Check your browser settings.
Check your browser settings.
It has nothing to do with browser settings. .