我创建了打印客户发票的应用程序。我想打印两张发票编号之间的所有发票,例如打印10号发票到30号发票之间的所有发票。
我想通过单击或单个弹出窗口打印它们,或者不打印任何弹出窗口。
此代码生成多个弹出窗口
这是我的代码
$("#btnPrint").click(function () {
var invStartNo = 10;
var invUptoNo = 30;
for (var i = invStartNo; i < invUptoNo; i++) {
var contents = functionWhichReturnHTML_byInvNo(i);//this function return dynamically html by invoice no
var frame1 = $('<iframe />');
frame1[0].name = "frame1";
frame1.css({ "position": "absolute", "top": "-1000000px" });
$("body").append(frame1);
var frameDoc = frame1[0].contentWindow ? frame1[0].contentWindow : frame1[0].contentDocument.document ? frame1[0].contentDocument.document : frame1[0].contentDocument;
frameDoc.document.open();
//Create a new HTML document.
frameDoc.document.write('<html><head><title>Account Statement</title>');
frameDoc.document.write('</head><body>');
//Append the external CSS file.
frameDoc.document.write('<link href="../../Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />');
//Append the DIV contents.
frameDoc.document.write(contents);
frameDoc.document.write('</body></html>');
frameDoc.document.close();
setTimeout(function () {
window.frames["frame1"].focus();
window.frames["frame1"].print();
frame1.remove();
}, 1000);
}
});
答案 0 :(得分:0)
var invStartNo = 10;
var invUptoNo = 30;
for (var i = invStartNo; i < invUptoNo; i++) {
var contents = functionWhichReturnHTML_byInvNo(i);//this function return dynamically html by invoice no(call synchronously)
//Append the DIV contents.
frameDoc.document.write(contents);
}