2017-05-17 239 views
0

此流星客户端代码适用于Android Chrome浏览器。它打开打印对话框并打印。它还打开MacBook Chrome上的对话框打印,但对话框页面未能显示html的内容。它需要在所有设备上工作。
在Mac Safari上尝试时,浏览器闪烁但未能一起打开打印机对话框。打开html页面打印

任何想法如何显示内容,以便它在打印“打印”按钮时不打印空白页面? thx

编辑
它可以在Windows Firefox上找到。
删除return true

Mac工作正常,它在Mac Safari上无法正常工作。

print:() => { 
     let data = $('form').html(); 
     let w = window.open(); //opens in a new tab 
     w.document.write('<html><head><title>Print Document</title>'); 
     w.document.write('</head><body>'); 
     w.document.write(data); 
     w.document.write('</body></html>'); 

     w.document.close(); // necessary for IE >= 10 
     w.focus(); // necessary for IE >= 10 
     w.print(); 
     w.close(); 
     return true; 
    }, 

回答

0

尝试用setTimeout

setTimeout(function(){ 
    w.focus(); 
},2000); 
+0

该解决方案在浏览器中加载了停止页面。 –

+0

它对我有用 – lalithkumar

+0

不需要返回true – lalithkumar