troubleshooting Question

Javascript print function no longer works

Avatar of Susan Faul
Susan Faul asked on
ASP.NETWindows 10JavaScriptWindows OSWindows 7
6 Comments1 Solution82 ViewsLast Modified:
I have javascript code in an aspx page to print 4 copies of a document from one button click  (see code below).  When using Windows 7 and Internet Explorer, this worked fine.  Now with Windows 10, it no longer works.  It will print 1 copy only.  Anyone have any suggestions?  

<input type="button" id="btnPrint" name="button" value="Print Stuff" onclick="JavaScript:PrintPart('PrintThisPart');return false;");  />



 
  function PrintPart(elementID) {
        var printContent = document.getElementById(elementID);
        var printWindow = window.open('', '', 'left=50000,width=0,height=0');

        document.getElementById('ctl00_ContentPlaceHolder2_btnA').click();

        document.getElementById('dontprint').style.display = 'none';
        document.getElementById('dontprintHistory').style.display = 'none';

        document.getElementById('ctl00_ContentPlaceHolder2_txtNotes').style.display = 'none';
        document.getElementById('ctl00_ContentPlaceHolder2_lblNotes').style.display = 'none';

        document.getElementById('ctl00_ContentPlaceHolder2_lbl1').style.fontSize = "22px";

        document.getElementById('ctl00_ContentPlaceHolder2_lblCopyTo').innerHTML = '' +
                     Name: _______________________________________ <br />' +
                     Date:____________________________________ <br />' +
                     '<br /><br /> COPY ONE';

        printWindow.document.write(printContent.innerHTML);
        printWindow.document.close();
        printWindow.focus();
        printWindow.print();

        document.getElementById('ctl00_ContentPlaceHolder2_lbl1').innerHTML = 'COPY TWO';
        printWindow.document.write(printContent.innerHTML);
        printWindow.document.close();
        printWindow.focus();
        printWindow.print();

        document.getElementById('ctl00_ContentPlaceHolder2_lbl1').innerHTML = 'COPY THREE';
        printWindow.document.write(printContent.innerHTML);
        printWindow.document.close();
        printWindow.focus();
        printWindow.print();

        document.getElementById('ctl00_ContentPlaceHolder2_lbl1').innerHTML = 'COPY FOUR';

        printWindow.document.write(printContent.innerHTML);
        printWindow.document.close();
        printWindow.focus();
        printWindow.print();

        printWindow.close();

    }
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros