Is there a way to close the active tab in the browser after I sent the data to the reprint?
<script> window.print(); </script> It means, how to make so that after clicking the "Print" button, the tab is automatically closed? 
Is there a way to close the active tab in the browser after I sent the data to the reprint?
<script> window.print(); </script> It means, how to make so that after clicking the "Print" button, the tab is automatically closed? 
In order for you to close a tab using JavaScript, you need to open it using JavaScript.
For example:
On the page with the submit button
<input value="Печатать" onclick="window.open('http://mysite.ru/print-page')" type="button"> On the page mysite.ru/print-page
<script> setTimeout(function(){window.print();}, 500); window.onfocus = function(){setTimeout(function(){window.close();}, 500);}; <script> The delay in this case is necessary so that in such browsers as Chrome the print window does not close before calling the print method.
Source: https://ru.stackoverflow.com/questions/540590/
All Articles