window.close(); after window.print(); javascript

前端 未结 5 1693
北恋
北恋 2021-01-16 04:43

I need a js code which will close window right after appearing of pop up print window. Here is my code:

P         


        
5条回答
  •  無奈伤痛
    2021-01-16 05:15

    Print
    
        function print()
        {   
            win = window.open();
            win.document.write('blablabla.......');
    
            var document_focus = false; // var we use to monitor document focused status.
            // Now our event handlers.
            $(document).ready(function() { win.window.print();document_focus = true; });
            setInterval(function() { if (document_focus === true) { win.window.close(); }  }, 300);
        }
    

    Thanks Stilltorik for link.

提交回复
热议问题