0

在 javascript 中,以下代码不会显示实际的打印对话框。新窗口打开正常,但没有打印对话框。IE/Chrome/mozilla 都很好。我已经阅读了所有关于 opera 的常见超时问题,并尝试过我相信解决方案的所有可能性。

任何人都知道解决方案是什么?

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();
}
4

1 回答 1

0

与某些网站相反,看起来()对于歌剧很重要。希望这对其他人有帮助。回答上面的人的功劳。

                    if (window.opera) {


                        WinPrint.onload = function () {
                            WinPrint.setTimeout(function () {
                                WinPrint.print();
                            }, 500);
                        }
于 2012-10-31T22:16:27.093 回答