1. <tfoot id='IcSvc'></tfoot>
      <legend id='IcSvc'><style id='IcSvc'><dir id='IcSvc'><q id='IcSvc'></q></dir></style></legend>

      <small id='IcSvc'></small><noframes id='IcSvc'>

      1. <i id='IcSvc'><tr id='IcSvc'><dt id='IcSvc'><q id='IcSvc'><span id='IcSvc'><b id='IcSvc'><form id='IcSvc'><ins id='IcSvc'></ins><ul id='IcSvc'></ul><sub id='IcSvc'></sub></form><legend id='IcSvc'></legend><bdo id='IcSvc'><pre id='IcSvc'><center id='IcSvc'></center></pre></bdo></b><th id='IcSvc'></th></span></q></dt></tr></i><div id='IcSvc'><tfoot id='IcSvc'></tfoot><dl id='IcSvc'><fieldset id='IcSvc'></fieldset></dl></div>
          <bdo id='IcSvc'></bdo><ul id='IcSvc'></ul>

        谷歌浏览器在打印预览中不显示图像

        时间:2023-09-30
        • <small id='VM9yZ'></small><noframes id='VM9yZ'>

            • <bdo id='VM9yZ'></bdo><ul id='VM9yZ'></ul>
              <i id='VM9yZ'><tr id='VM9yZ'><dt id='VM9yZ'><q id='VM9yZ'><span id='VM9yZ'><b id='VM9yZ'><form id='VM9yZ'><ins id='VM9yZ'></ins><ul id='VM9yZ'></ul><sub id='VM9yZ'></sub></form><legend id='VM9yZ'></legend><bdo id='VM9yZ'><pre id='VM9yZ'><center id='VM9yZ'></center></pre></bdo></b><th id='VM9yZ'></th></span></q></dt></tr></i><div id='VM9yZ'><tfoot id='VM9yZ'></tfoot><dl id='VM9yZ'><fieldset id='VM9yZ'></fieldset></dl></div>

                1. <tfoot id='VM9yZ'></tfoot><legend id='VM9yZ'><style id='VM9yZ'><dir id='VM9yZ'><q id='VM9yZ'></q></dir></style></legend>

                    <tbody id='VM9yZ'></tbody>
                  本文介绍了谷歌浏览器在打印预览中不显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一些代码来创建一个弹出窗口,写一些 html 并打印.谷歌浏览器没有在打印预览中显示图像,但其他浏览器工作正常.在我的情况下,文件 Logo_big.png 丢失了.我怎样才能让它在 Chrome 中也能工作?

                  I have some code to create a pop-up write some html and print. Google Chrome is not showing images in the print preview, but other browsers are working fine. The file Logo_big.png is missing in my case. How can I get it to work in Chrome also?

                  我的代码:

                  var newWindow = window.open('', '', 'width=100, height=100'),
                          document = newWindow.document.open(),
                          pageContent =
                              '<!DOCTYPE html>' +
                              '<html>' +
                              '<head>' +
                              '<meta charset="utf-8" />' +
                              '<title>Inventory</title>' +
                              '<style type="text/css">body {-webkit-print-color-adjust: exact; font-family: Arial; }</style>' +
                              '</head>' +
                              '<body><div><div style="width:33.33%; float:left;"><img src="img/Logo_big.png"/></body></html>';
                          document.write(pageContent);
                          document.close();
                          newWindow.moveTo(0, 0);
                          newWindow.resizeTo(screen.width, screen.height);
                          newWindow.print();
                          newWindow.close();
                  

                  推荐答案

                  这里的问题是,一旦设置了 src,javascript 没有给 DOM 足够(任何)时间来加载/渲染图像.

                  The issue here is javascript not giving the DOM enough (any) time to load / render the image once it has the src set.

                  您需要留出时间让浏览器加载/渲染(从缓存或其他方式)图像,您可以通过设置 setTimeout 来延迟正在设置的内容的打印.

                  You need to allow time for the browser to load / render (from cache or otherwise) the image, you can do so by setting a setTimeout to delay the printing from the content being set.

                  这个特定问题的一个例子是:

                  An example for this specific question would be:

                  var newWindow = window.open('', '', 'width=100, height=100'),
                  document = newWindow.document.open(),
                  pageContent =
                      '<!DOCTYPE html>' +
                      '<html>' +
                      '<head>' +
                      '<meta charset="utf-8" />' +
                      '<title>Inventory</title>' +
                      '<style type="text/css">body {-webkit-print-color-adjust: exact; font-family: Arial; }</style>' +
                      '</head>' +
                      '<body><div><div style="width:33.33%; float:left;"><img src="img/Logo_big.png"/></body></html>';
                  document.write(pageContent);
                  document.close();
                  newWindow.moveTo(0, 0);
                  newWindow.resizeTo(screen.width, screen.height);
                  setTimeout(function() {
                      newWindow.print();
                      newWindow.close();
                  }, 250);
                  

                  您设置的 setTimeout 越低,浏览器加载图像的时间就越少,因此您需要对此进行调整,并在适用的情况下考虑到较慢的互联网连接/浏览器.

                  The lower you set the setTimeout, the less time the browser will have to load the image so you will need to adjust this and account for slower internet connections / browsers where applicable.

                  这篇关于谷歌浏览器在打印预览中不显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:将鼠标悬停在热点上时带有图像弹出窗口的图像映射 下一篇:HTML - JS 如何通过单击在图像弹出窗口中打开图像?

                  相关文章

                2. <small id='vTew6'></small><noframes id='vTew6'>

                  <i id='vTew6'><tr id='vTew6'><dt id='vTew6'><q id='vTew6'><span id='vTew6'><b id='vTew6'><form id='vTew6'><ins id='vTew6'></ins><ul id='vTew6'></ul><sub id='vTew6'></sub></form><legend id='vTew6'></legend><bdo id='vTew6'><pre id='vTew6'><center id='vTew6'></center></pre></bdo></b><th id='vTew6'></th></span></q></dt></tr></i><div id='vTew6'><tfoot id='vTew6'></tfoot><dl id='vTew6'><fieldset id='vTew6'></fieldset></dl></div>
                    <legend id='vTew6'><style id='vTew6'><dir id='vTew6'><q id='vTew6'></q></dir></style></legend>
                    1. <tfoot id='vTew6'></tfoot>

                        <bdo id='vTew6'></bdo><ul id='vTew6'></ul>