【问题标题】:how can I print this voucher to A4 size paper? [duplicate]我如何将这张凭证打印到 A4 尺寸的纸上? [复制]
【发布时间】:2017-01-05 06:20:20
【问题描述】:
<script>
function myFunction() {


window.print();
}
</script>
<form >
<input type="submit" value="Submit">
</form>

但我只需要打印 Just My table Tr

【问题讨论】:

    标签: javascript css printing


    【解决方案1】:

    从这里挑选代码Print a div content using Jquery

    function myFunction() 
    {
    
      var divToPrint=document.getElementById('IdOfDivTobePrinted');
    
      var newWin=window.open('','Print-Window');
    
      newWin.document.open();
    
      newWin.document.write('<html><body onload="window.print()">'+divToPrint.innerHTML+'</body></html>');
    
      newWin.document.close();
    
      setTimeout(function(){newWin.close();},10);
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-18
      • 1970-01-01
      • 2020-06-04
      • 1970-01-01
      • 1970-01-01
      • 2012-09-04
      • 1970-01-01
      • 2012-03-31
      相关资源
      最近更新 更多