0

enter image description here

Explanation : Here as you can see in image there are two windows open in Microsoft Edge browser to print pdf file. But I want to close my external window after opening a print preview window. I have mention windows title in image.

My Try :

    var mywindow = window.open('', 'mywindow', 'height=600,width=800');
    var html = '<html><head><title></title><style type="text/css" media="print">@@page  {  size: auto; margin: 5mm 0mm 0mm 10mm;  } </style>' +               
               '</head><body>' +
               contents +
               '</body></html>';

    mywindow.document.write(html);
    mywindow.document.close();
    mywindow.focus();
    mywindow.print();
    mywindow.close();

I have also refer some link as below.

https://stackoverflow.com/a/6040795/2798643

https://stackoverflow.com/a/11782214/2798643

https://stackoverflow.com/a/9616706/2798643

and many more links. So if anyone have any idea about it than let us know.

Community
  • 1
  • 1
Govinda Rajbhar
  • 2,926
  • 6
  • 37
  • 62
  • "But I want to close my external window after opening a print preview window"?? Heh? – An0nC0d3r Oct 21 '15 at 12:43
  • @AdamJeffers yes i want to close my external window which is exact behind of print preview window as you can see in image. – Govinda Rajbhar Oct 21 '15 at 12:46
  • But the microsoft edge print preview "belongs" with the external window so without closing the print preview down first, you won't be able to close the main window? – An0nC0d3r Oct 21 '15 at 12:49
  • @AdamJeffers so do you have any other suggestion or idea to resolve this issue. – Govinda Rajbhar Oct 21 '15 at 12:51
  • Not if you want to keep the print preview window to remain.... I don't believe it's possible. Any reason why you're looking at doing it this way? Can we think of a better way? – An0nC0d3r Oct 21 '15 at 12:52
  • There is no any specific reason but in chrome there is no external window in a UI that is why i am trying this. – Govinda Rajbhar Oct 21 '15 at 12:57
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/92962/discussion-between-govindarajbhar-and-adamjeffers). – Govinda Rajbhar Oct 21 '15 at 13:03

0 Answers0