我已经创建了一个div,里面有一些css应用(通过css文件)。现在我想从整个页面打印特定的div。我面临的问题是所有的css类都应用在打印对话框中,但不应用背景颜色。html的背景颜色没有默认打印dialoag框
这里是打印按钮的我的代码块,打开一个默认的打印对话框:
$("#btnPrint").click(function() {
var contents = $("#Call").html();
var frame1 = $('');
frame1[0].name = "frame1";
frame1.css({ "position": "absolute", "top": "-1000000px" });
$("body").append(frame1);
var frameDoc = frame1[0].contentWindow ? frame1[0].contentWindow : frame1[0].contentDocument.document ? frame1[0].contentDocument.document : frame1[0].contentDocument;
frameDoc.document.open();
//Create a new HTML document.
frameDoc.document.write('
Call');frameDoc.document.write('
');//Append the external CSS file.
frameDoc.document.write('');
//Append the DIV contents.
frameDoc.document.write(contents);
frameDoc.document.write('');
frameDoc.document.close();
setTimeout(function() {
window.frames["frame1"].focus();
window.frames["frame1"].print();
frame1.remove();
}, 500);});
这里是我的网页上的div:
这里是打印对话框,显示预览该div:
请帮我申请后台打印对话框。
感谢
+0
铬布局更改打印设置。取消勾选“block bg”。它在“更多设置”中 –
+0
尽管 –
+0
可能与http:// stackoverflow重复,但不能使用代码进行更改。com/questions/3893986/css-media-print-issues-with-background-color –