We help IT Professionals succeed at work.
Get Started

Javascript print function no longer works

78 Views
Last Modified: 2020-10-15
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();

    }

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE