js window.open then print()

后端 未结 7 1894
深忆病人
深忆病人 2020-11-29 08:14

print() doesn\'t work in IE after opening a new window. It works in Chrome. Here\'s a tester:





        
7条回答
  •  失恋的感觉
    2020-11-29 08:56

    As most of browsers has been updated, So print and close do not any more as It worked before. So you should add onafterprint event listener in order to close print window.

        var printWindow = window.open('https://stackoverflow.com/');
        printWindow.print();
    
        //Close window once print is finished
        printWindow.onafterprint = function(){
           printWindow.close()
        };
    

提交回复
热议问题