【问题标题】:Window with Image - Print() Issue in Chrome带有图像的窗口 - Chrome 中的 Print() 问题
【发布时间】:2014-08-20 04:22:29
【问题描述】:

我正在通过打开一个新窗口并使用 .print() 函数来打印文档。

文档也有图像。但在 chrome 中,它打印时没有图像。

在打印 [setTimeout] 之前添加了一些延迟以完成加载图像,但没有帮助。 它打印了图像的一半。

       function PrintContent() {
                var DocumentContainer = document.getElementById(rClientID);
                var WindowObject = window.open('', "PrintOrder",
                          "width=740,height=325,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=no");
                WindowObject.document.open();
                WindowObject.document.writeln(DocumentContainer.innerHTML);
                WindowObject.document.close();
                WindowObject.focus();
                WindowObject.print();
                //WindowObject.close();
                return false;
        }

【问题讨论】:

    标签: javascript html google-chrome printing


    【解决方案1】:

    修改了打印行,onload-event上打印窗口对象,

    应该只在加载页面后调用。

    似乎工作正常。

    WindowObject.onload = function() { WindowObject.print() };
    

    【讨论】:

      【解决方案2】:

      解决方法是在body标签中加入onLoad事件:

       WindowObject.document.write('<html><header><title></title></header>');
       WindowObject.document.write('<body onLoad="self.print(); self.close()">');
       WindowObject.document.write(DocumentContainer.innerHTML);
       WindowObject.document.write('</body></html>');
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-26
        • 1970-01-01
        • 2014-11-22
        • 1970-01-01
        • 2018-09-21
        相关资源
        最近更新 更多