Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.close() not working in Microsoft Edge browser

In Microsoft Edge, window.close() is not working in child windows after closing a print dialog.

Steps to reproduce:

  1. Open a print dialog from a child window.
  2. Close it.

After closing the print dialog, the close button of the child window is not closing it.

Code for parent window:

    <script type="text/javascript">
    function openChild(){ 
       window.open("childWindow.html", "", "width=600, height=400"); 
    }
    </script>
    </head>
    <body>
        <input type="button" value="Open Child Window" onclick="openChild()" />
    </body>

Code for child window:

<script type="text/javascript">
    function closeWindow(){
        window.close();
    }
    function printPage() {
        window.print();
    }
    </script>
    </head>
    <body>
        <input type="button" value="Print" onclick="printPage()" />
        <input type="button" value="Close Window" onclick="closeWindow()" style="float: right" />
    </body>
like image 611
Nitin Sharma Avatar asked Oct 05 '15 23:10

Nitin Sharma


1 Answers

Im not sure if this is related, but I saw an article where window.close() will not work in edge after a print dialog has been canceled. Maybe it is the same bug? Microsoft support article

like image 108
TinMonkey Avatar answered Sep 21 '22 02:09

TinMonkey