2017-05-17 244 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