I have a very simple javascript function to print the current page:
<script>
function printpage() {
window.print();
alert("PRINTING...");
}
</script>
and the call:
<a href="#" onclick="printpage()" data-role="button" data-theme="j">Print</a>
If I remove the alert the print popup box doesn't show until I refresh the page. With the alert there is a short pause and then it shows, I would prefer not to have any alert. I tried doing a console.log instead so an event would happen invisibly to the user and still fire the function but it didn't work.
The solution posted here works great for single divs and fires immediately but I need to print the entire page and would prefer to stick with a simple window.print()
.
EDIT: More details, when I click refresh, the print dialog pops up and the page does not refresh until you actually close the dialog, similar to the way the dialog doesn't show until I close the alert.