JavaScriptから印刷するこのコードを見つけました。ただし、印刷するドキュメントを含むウィンドウが開きます。その文書を非表示にする方法はありますか?
var element=document.getElementById(element_id);
var newWin=window.open('','Print-Window','width=400,height=400,top=100,left=100');
newWin.document.open();
/* newWin.document.title = "Readings on PageLinks"; */
newWin.document.write('<html><head><title>Readings on PageLinks</title></head><body onload="window.print()">'+element.innerHTML+'</body></html>');
newWin.document.close();
setTimeout(function(){ newWin.close(); },10);
そのドキュメントの印刷は onload() で行われるので、それなしでは印刷はできないと思います。しかし、それを隠すことはできますか?