Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
closing the pop up window after clicking on cancel

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!