我想在 div 内容打印完成后停止打印。问题是,如果内容很少,页面的其余部分就会出现空白。我想在内容打印完成后剪切页面。我正在使用收据打印机。
function Popup(data)
{
var mywindow = window.open('', 'day', 'height=300,width=400');
mywindow.height
mywindow.document.write('<html><head><title>my div</title>');
mywindow.document.write('<link rel="stylesheet" href="style.css" type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.print();
return true;
}
最佳答案
您可以定义 css 以在元素后创建分页符。
@media print
{
.some_element {page-break-after:always;}
}
关于javascript - 打印完 div 内容后停止打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24106301/