如何在asp.net上使用Javascript在ButtonClick上打印没有打印预览的网页

时间:2017-06-22 09:03:55

标签: javascript c# html asp.net

我写了这段代码,但仍然打印预览选项......

this.contentWindow.print()用于打印目的

<!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>

0 个答案:

没有答案