在window.load之后加载和打印Chrome弹出窗口

时间:2013-10-17 15:18:12

标签: jquery google-chrome popup font-face

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

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

});

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

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分: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();