Question: print() doesn't work in IE after opening a new window. It works in Chrome.
Here's a [tester](http://www.w3schools.com/js/tryit.asp?filename=try_win_focus):

```
<html>
<head>
<script type="text/javascript">
  function openWin()
  {
    myWindow=window.open('','','width=200,height=100');
    myWindow.document.write("<p>This is 'myWindow'</p>");
    myWindow.focus();
    myWindow.print(); //DOES NOT WORK
  }
</script>
</head>
<body>

<input type="button" value="Open window" onclick="openWin()" />

</body>
</html>

```

Answer: 
Turgut gave the right solution. Just for clarity, you need to add close after writing.

```
function openWin()
  {
    myWindow=window.open('','','width=200,height=100');
    myWindow.document.write("<p>This is 'myWindow'</p>");

    myWindow.document.close(); //missing code

    myWindow.focus();
    myWindow.print(); 
  }

```
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()
    };

```