gpt4 book ai didi

javascript - 使用 qzprint (jzebra) 时出现 IE 和未指定错误

转载 作者:行者123 更新时间:2023-11-28 08:16:42 25 4
gpt4 key购买 nike

您好,我正在尝试打印 HTML 页面。它可以在除 IE 之外的所有其他浏览器中打印。在 IE 中,它在 html2canvas.js 中给出了“未指定错误”html2canvas.js 的版本是0.34。我尝试过使用最新版本,即 0.4.1,但在其他时候失败。小程序提供的sample.html 工作正常,我的大部分代码都是从中借用的。

错误发生在html2canvas.js中以下代码的最后一行

_html2canvas.Util.Bounds = function getBounds (el) {
var clientRect,
bounds = {};

if (el.getBoundingClientRect){
clientRect = el.getBoundingClientRect();

非常感谢任何线索和提示。

这是我的代码

$(document).ready(function () {

useDefaultPrinter(function () {

if (!isLoaded()) {
alert("Printer is not loaded, please try again.");
return;
}

window['qzDonePrinting'] = function () {
// After print functionality
if ($('input[name=action]').length > 0)
document.getElementById('frm_next').submit();
else {
var query_param = 'coid=8EY76KFTYGWF6';
send_ajax_request(query_param, function () {
var href = '/path/to/homepage';
if (JSON_data.SUCCESS == 1)
href += '?coid=' + JSON_data.RET_COID;
window.location.href = href;
});
}

// Remove reference to this function
window['qzDonePrinting'] = null;
};
printHTML5Page();
});
});

function printHTML5Page() {
$("body").html2canvas({
canvas: hidden_screenshot,
onrendered: function() {
if (notReady()) { return; }
// Optional, set up custom page size. These only work for PostScript printing.
// setPaperSize() must be called before setAutoSize(), setOrientation(), etc.
qz.setPaperSize("8.5in", "11.0in"); // US Letter
qz.setAutoSize(true);
qz.appendImage($("canvas")[0].toDataURL('image/png'));
// Automatically gets called when "qz.appendFile()" is finished.
window['qzDoneAppending'] = function() {
// Tell the applet to print.
qz.printPS();

// Remove reference to this function
window['qzDoneAppending'] = null;
};
}
});
}

提前非常感谢您的所有意见。

最佳答案

html2canvas 依赖于 HTML5 规范,旧版本的 Internet Explorer 不支持该规范。根据您的 IE 版本,您的浏览器可能不支持此功能。

关于javascript - 使用 qzprint (jzebra) 时出现 IE 和未指定错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23503467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com