How do I print a web page without opening a pop-up?


I want to print a web page using JavaScript. But I do not want to open the page as a popup windows. How can I print directly a web page like 'mypage.aspx' using JavaScript window.print method without opening it as a popup window?

Also the condition is 'I don't want to use any ActiveX for this'

Here is what I want to try:

var printWindow, printData; printWindow ="", "printVersion", "menubar,scrollbars,width=640,height=480,top=0,left=0");

printData=document.getElementById("lblReport").innerHTML; printWindow.document.write(printData);

The simpliest solution is to load the content of that mypage.aspx to an iframe then on iframes onload event call the window.print.

<button onclick="printPage()">print</button>
<div id="printerDiv" style="display:none"></div>
   function printPage()
      var div = document.getElementById("printerDiv");
      div.innerHTML = '<iframe src="mypage.aspx" onload="this.contentWindow.print();"></iframe>';