【问题标题】:Unable to load image in multiple window.print()无法在多个 window.print() 中加载图像
【发布时间】:2018-01-03 05:39:00
【问题描述】:

当我使用下面的代码时,我在 for 循环中出现带有图像的打印收据问题 使用 for 循环进行多次打印时,它不会加载图像(单张打印效果很好)但我删除了图像参考,它工作正常。 所以,请给我解决方案。

 function printReceipt() {

        for (var index = 0; index < 10; index++) {

            var imageData = '<img src="./images/image.png"/>';

            var newWin = window.open('', 'Print-Window');
            newWin.document.open();
            newWin.document.write('<html><title>WEB</title><body onload="window.print()">' + imageData + '</body></html>');
            newWin.document.close();
            setTimeout(function () {
                newWin.close();
            }, 200);
        }
    }

    printReceipt();

【问题讨论】:

标签: javascript html dom


【解决方案1】:

查看此链接可能对您有所帮助: Help Link

如果找不到图片,请尝试提供 alt 属性,这可能是您的 URL 不正确:
var imageData = '&lt;img src="./images/image.png" alt="Smiley face" /&gt;';

【讨论】:

  • 然后检查我提供给你的链接
猜你喜欢
  • 2013-12-02
  • 2015-12-16
  • 2019-05-08
  • 2021-03-09
  • 2019-05-30
  • 2020-01-20
  • 2013-07-01
  • 2013-04-12
  • 1970-01-01
相关资源
最近更新 更多