js window.open then print()

Clive picture Clive · Mar 24, 2012 · Viewed 135.7k times · Source

print() doesn't work in IE after opening a new window. It works in Chrome. Here's a tester:

<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 picture Turgut · Mar 24, 2012