繁体   English   中英

完成div内容打印后停止打印

[英]stop printing after done printing div content

我想在完成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;}
}

请参阅此处的参考http://www.w3schools.com/cssref/pr_print_pageba.asp

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM