Cannot reload page by reload JS function after click print button
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>