I am printing on the click of the button using javascript. when I click on the button, two windows open, one is the actual print window and another one os the pop that shows the content that needs to be printed. when I click on the cancel or print button, I want the pop to be closed. How can I achieve that. Below is the code:
<script>
function printDiv() {
var divContents = document.getElementById("GFG").innerHTML;
var a = window.open('', '', 'height=500, width=500');
a.document.write('<html>');
a.document.write('<body > <h1>Div contents are <br>');
a.document.write(divContents);
a.document.write('</body></html>');
a.document.close();
a.print();
}
</script>
<body style="text-align:center;">
<div class="container" id="GFG">
<div class="row justify-content-center">
<div class="col-sm-4">
<asp:GridView ID="grdCalculate" runat="server" GridLines="Horizontal" Width="100%"
CssClass="table table-responsive table-hover table-striped table-bordered table-condensed">
</asp:GridView>
</div>
</div>
</div>
<input type="button" value="click" onclick="printDiv()">
</body>
I want to get rid of the pop-up when the print or cancel button is clicked.