When using JavaScript, I encountered an issue where the print dialog box would not appear. The new window would open successfully, but the print dialog was missing. This problem only occurred in Opera, while IE, Chrome, and Mozilla worked fine. I have researched the usual timeout issues related to Opera and tried multiple solutions, but none of them seem to work.
Does anyone have any idea what the solution might be?
var windowUrl = 'about:blank';
var UserLoggedIn = $("#lblUser").text()
var now = new Date();
var strDateTime = [
[AddZero(now.getDate()), AddZero(now.getMonth() + 1), now.getFullYear()].join("/"), [AddZero(now.getHours()), AddZero(now.getMinutes())].join(":"), now.getHours() >= 12 ? "PM" : "AM"].join(" ");
var Database = 'ProductionDatabase';
var windowName = 'Report';
var AuditPrintDetailEverypage = UserLoggedIn + ' Time : ' + strDateTime;
var AuditPrintDetailLastPage = ' Report ' + ' Source Database: ';
var WinPrint = window.open(windowUrl, windowName, 'left=300,top=300,right=500,bottom=500,width=1000,height=500,scrollbars=1');
WinPrint.document.write('<' + 'html' + '><head><link href="assets/css/Print.css" rel="stylesheet" type="text/css" /><title>' + AuditPrintDetailEverypage + '</title> </head><' + 'body style="background:none !important"' + '>');
WinPrint.document.write(printContent.innerHTML);
WinPrint.document.write(' ' + AuditPrintDetailLastPage);
WinPrint.document.write('<' + '/body' + '><' + '/html' + '>');
WinPrint.document.close();
if (window.opera) {
window.onload = function () {
window.setTimeout(function () {
window.print;
}, 500);
}
} else {
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}