user3490546
user3490546

Reputation: 292

window.print() not working in ie and already tried proper fixes

I would like to print a whole page when a button is clicked. I am using window.print() but its not working for ie. I googled for a solution but nothing hellped. Maybe someone know what I am doing wrong.

MyCode:

$('#PrintTool').click(function () {
var printVal = document.documentElement.innerHTML;
var newWin = window.open();
newWin.document.write(printVal);
newWin.document.close();
newWin.focus();
newWin.print();
newWin.close();
});

I hope you can help me

Upvotes: 0

Views: 6215

Answers (1)

Smudoo
Smudoo

Reputation: 547

checkout: window.print() not working in IE

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

<html>
<head>
<script type="text/javascript">
  function openWin()
  {
    var myWindow=window.open('','','width=200,height=100');
    myWindow.document.write("<p>This is 'myWindow'</p>");

    myWindow.document.close();
    myWindow.focus();
    myWindow.print();
    myWindow.close();

  }
</script>
</head>
<body>

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

</body>
</html>

Upvotes: 1

Related Questions