Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
Javascript: Issue with window.print

In recent update of browsers, (firefox 95+) Something weired happened.

Scenario:

- user clicks the print button in main page
- user will be redirected to a new page (print page)
- when the page fully loaded, the window.print() function executes
- when the print dialog dismissed, user will be redirected to main page

So for example, I wrote this html code:

<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body>
test
<script language="javascript">
    window.print();
    console.log('1');
</script>
</body>
</html>

As this page describes, The window.print() method will block while the print dialog is open. And its true. unless you have more script lines after that.

Opened an issue here and yet, the problem seems unsolved to me.

if you paste

window.print();
console.log('1');

directly into browser console, it works as it intended.

Any advise?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This works for me in current Safari and Chrome. The console log is executed after the print dialog is dismissed.

window.onafterprint = event => {
  console.log('after print');
};
window.print();

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!