Search code examples
javascripthtmlprintingwindow

js window.open then print()


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>

Solution

  • checkout: window.print() not working in IE

    Working sample: http://jsfiddle.net/Q5Xc9/1/