1

我有一个弹出窗口,我需要在 window.load 事件之后调用打印函数。我使用了这种语法:

var popup = window.open(.....);
$(popup).load(function() 
{
popup.print();

});

FF 中一切正常,但在 Web 字体完全加载之前 Chrome 打印函数调用。有什么问题?

4

2 回答 2

2

使用 <body onload="window.print()" > 而不是调用 popup.print()

于 2015-10-10T16:00:14.180 回答
1

您必须创建窗口打印并在新窗口中添加您的字体和其他 css 或 js 文件,然后显示它们。

var WinPrint = window.open('', '', 'width=842,height=595');
WinPrint.document.write('<html><head>');
WinPrint.document.write('<link rel="stylesheet" href="/Content/bootstrap.min.css">');
WinPrint.document.write('<link rel="stylesheet" href="/Content/Layout/font/persian-font.css">');
WinPrint.document.write('</head><body>');
WinPrint.document.write(document.getElementById('tagId').innerHtml);
WinPrint.document.write('</body></html>');
WinPrint.focus();
于 2018-10-02T06:08:17.083 回答