使用 Window.print 在 Firefox 浏览器中打印 Html

问题描述

这在 Google Chome 上运行良好。 当第一次使用 Firefox 时,表格行丢失,对齐也没有按预期显示。第二次它工作正常

<script language="javascript">
function PrintElem(elem) {
    document.getElementById('PrintBtn').style.visibility = 'hidden';
    var mywindow = window.open('','PRINT','height=400,width=600');
    mywindow.document.write('<html><head><title></title>');
    mywindow.document.write('</head><body >');
    /*mywindow.document.write('<h1>' + document.title + '</h1>');*/
    mywindow.document.write(document.getElementById(elem).outerHTML);
    mywindow.document.write('</body></html>');
    mywindow.document.close();
    mywindow.focus();        
    mywindow.print();
    setTimeout(function () { mywindow.close(); },10000);
    document.getElementById('PrintBtn').style.visibility = 'visible';
    return true;
}



//document.getElementById("printMe").style.height = (window.screen.height) - 100 + "px";
//document.getElementById("printMe").style.width = (window.screen.width) - 0 + "px";
//document.getElementById("printMe").style.overflowY = "auto";

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)