Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda