Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

113
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda