通过Jquery打印带有图像的动态生成的DIV
我动态生成一个图像,然后将该图像与一些文本一起嵌入到div中。我尝试通过名为jquery.printElement.min.js的jquery插件打印带有图像的动态div。该插件在firefox和IE中运行良好,但在Chrome中不起作用。这是我用来打印DIV的代码通过Jquery打印带有图像的动态生成的DIV,jquery,google-chrome,Jquery,Google Chrome,我动态生成一个图像,然后将该图像与一些文本一起嵌入到div中。我尝试通过名为jquery.printElement.min.js的jquery插件打印带有图像的动态div。该插件在firefox和IE中运行良好,但在Chrome中不起作用。这是我用来打印DIV的代码 $("#Print").click(function () { if (ImgPath != '') { var ImagePath = location.protocol + "//" +
$("#Print").click(function () {
if (ImgPath != '') {
var ImagePath = location.protocol + "//" + location.host + ImgPath;
alert("Your track number " + _TrackNumber);
sHtml = "<div id=dvPrint><table>";
sHtml += "<tr><td><img src=" + ImagePath + " height=600 width=400 border=0/></td></tr>";
sHtml += "<tr><td>" + $('#lblTxt').html() + "</td></tr>";
sHtml += "</table></div>";
var $dvPrint = $(sHtml);
$dvPrint.printElement();
}
else {
alert("Image not found for print");
}
return false;
});
我只是不知道我的代码中有什么问题,Chrome无法打印,而是打开了一个没有Chrome图像的打印预览对话框。如何分类。我需要为chrome使用其他插件吗。请导游。谢谢
Chrome support有一个长达两年的帖子,用户们都在抱怨Chrome缺少背景打印这样的基本功能是多么可笑
换言之:Chrome不会打印div的背景
查看此答案以了解更多详细信息:
不确定这是否有帮助,但是:我找到的解决方案是向元素[printPage]添加一个setTimeout;调用打印函数中的第105行。。。。。。setTimeoutfunction{element[printPage];},50;