我需要一个jQuery的事件,相当于jQuery onbeforeprint并且与onafterprint浏览器兼容.
我不能@media print在CSS上使用,因为我需要从文档中删除一些类,并在完成打印时添加这些类.
如果你要使用这样的打印功能,你可以按照你的意愿做......
$("#Print").click(function () {
var a = window.open('', '', 'scrollbars=yes,width=1000,height=650');
a.document.open("text/html");
a.document.write('<html><head>');
a.document.write('<link rel="stylesheet" href="css/default.css" />');
a.document.write('<link rel="stylesheet" href="css/print.css" />');
a.document.write('</head><body><br/>');
a.document.write($('#Content').html());
a.document.write('</body></html>');
a.document.close();
a.print();
});
Run Code Online (Sandbox Code Playgroud)