上的css在主页上,我尝试打印一个弹出窗口。 在Chrome上它可以工作,但在Firefox中它不起作用,它忽略了css文件。Firefox在无限循环中挂起并忽略window.print()
在Firefox中,窗口正在载入内容,但我不知道它是什么,因为我无法打开萤火虫。 格式化HTML看起来不错,但打印机不能获取css信息。 所以我虽然可以,因为他加载了一些东西。
HTML+JS
代码(小提琴不允许document.write
):
popup.css
:
对不起引擎收录,但代码是为大计算器。
Javascript Code
:
$(document).ready(function() {
$('.depart span').click(function(){
//close all popups
$('.popup').hide();
//open current popup
$(this).next().slideDown();
});
$('.close').click(function(){
// close all popups
$('.popup').slideUp();
});
$('span.printbutton').click(function(){
printPopup($(this));
});
});
function printPopup(data){
var popup = data.parent().parent().parent('div.popup');
mywindow = window.open('', 'my div', 'height=600,width=420');
mywindow.document.write('<html><head><title>Popup</title>');
mywindow.document.write('<link rel="stylesheet" media="screen" href="popup.css" type="text/css" />');
mywindow.document.write('<link rel="stylesheet" media="print" href="popup.css" type="text/css" />');
mywindow.document.write('</head>')
mywindow.document.write('<body class="popupwindow">')
mywindow.document.write('<div class="popup">')
mywindow.document.write(popup.html());
mywindow.document.write('</div>')
mywindow.document.write('</body></html>');
// mywindow.location.reload();
mywindow.focus();
mywindow.print();
setTimeout('mywindow.close();', 5000);
return true;
}
希望有人能够帮助。
编辑:一个新的提示发现,当弹出加载循环时,我不得不按下ESC键以取消循环,然后我可以按STRG + P,它工作正常。 哪里可能是错误?
弹出窗口看起来不错,也是css信息。 唯一的问题是,打印机不能获取信息。 – demonking
Awwesssome @demonking – vijay