0

I wrote this code but still print preview option is coming...

this.contentWindow.print() for printing purpose

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
     <script>
   function printPage()
   {
      var div = document.getElementById("printerDiv");
      div.innerHTML = '<iframe src="PrintDemo.aspx" onload="this.contentWindow.print();"></iframe>';
   }
</script>
</head>

<body>
    <form id="form1" runat="server">
    <div>
    <button onclick="printPage()">prin`enter code here`t</button>
<div id="printerDiv" ">
    This Page Is for print demo`enter code here`
</div>

    </div>
    </form>
</body>
</html>
Frost_Mourne
  • 342
  • 4
  • 22
Ash
  • 23
  • 1
  • 5
  • You can't. It's a client thing. – VDWWD Jun 22 '17 at 09:36
  • This may work only on Chrome- https://stackoverflow.com/questions/4849952/google-chrome-extension-print-the-page-silently/9320649#9320649. Try and check in other browsers as well – Souvik Ghosh Jun 22 '17 at 09:39

0 Answers0