从firefox,IExplorer打印时显示表格边框

时间:2013-03-08 18:48:25

标签: javascript printing

我正在尝试在firefox和IE中打印页面的一部分,打印视图在Chrome中运行正常,但在Firefox或IE中无效。我看到没有抛出任何错误。

有什么想法吗?

这是我的css。

@media print{
    #header { display:none; }
}
body { font-size:16px; }
#footer { display:none; }

table {
    font-size:16px; margin-top:2px; 
    border:solid #000 !important;
    border-width:1px 0 0 1px !important;
}
th, tr {
    width: 100px; 
    text-align:right;
    padding-right: 5px; 
    border:solid #000 !important;
    border-width:0 1px 1px 0 !important;
}

tbody td { width:130px; text-align:right;padding-right: 5px; border:1px solid #000; }
h4 { font-size: 1.2em; }
h2 { font-size: 1.3em; }

这是我的打印功能:

function printAllTable(id) {
            var html = "<html>";
            html += "<head>";
            html += "</head><body>";
            html += document.getElementById("allcompheader").innerHTML;
            html += document.getElementById(id).innerHTML;
            html += "</body></html>";
            var printview = window.open('', '', 'width=950,height=900');
            printview.innerWidth = screen.width;
            printview.innerHeight = screen.height;
            printview.screenX = 0;
            printview.screenY = 0;
            printview.document.write(html);
            printview.print(); 
        }

... HTML

<input id="printCombinedSummary" type="button" value="Print" onclick="printAllTable('AllCompanySummaryTable')"/>

0 个答案:

没有答案