Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Lolu chungechunge lwabekwa kunqolobane. Uyacelwa ubuze umbuzo omusha uma udinga usizo.

Cannot reload page by reload JS function after click print button

  • Akukho zimpendulo
  • 1 inale nkinga
  • 13 views
more options

I wrote a JS function in order to print the modal window in the page and reload page link after print done. But I faced problem that after I click print button, the reload function didn't working. Below are the JS source code

<script language="javascript" type="text/javascript"> function printDiv(divName) {

 var printContents = window.document.getElementById(divName).innerHTML;
 document.body.innerHTML = printContents;
 window.print();

// window.location.href= window.location.href; // window.history.go(0); }; window.onafterprint = function() {

   window.location.reload(true);

}; </script>

I wrote a JS function in order to print the modal window in the page and reload page link after print done. But I faced problem that after I click print button, the reload function didn't working. Below are the JS source code <script language="javascript" type="text/javascript"> function printDiv(divName) { var printContents = window.document.getElementById(divName).innerHTML; document.body.innerHTML = printContents; window.print(); // window.location.href= window.location.href; // window.history.go(0); }; window.onafterprint = function() { window.location.reload(true); }; </script>