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

173
Visualizações
window.print() doesn't work on mobile browswer

I'm using this function to open a new tab with the html content take from another file and then print it. When I use it on a descktop browser it works fine. It opens a new tab with the content give and prints the page but when I try to do it from my mobile device the tab opens with its content and then I get the printer popup window but it says "There was a problem printing the page. Please try again." I've tried to press retry but it doesn't do anything.

Here's the function.

    function printit() {
    var rawFile = new XMLHttpRequest();
    rawFile.open("GET", "/Doc/New Text Document.html", false);
    rawFile.onreadystatechange = function () {
        if (rawFile.readyState === 4) {
            if (rawFile.status === 200 || rawFile.status == 0) {
                var allText = rawFile.responseText;
                var myWindow = window.open('about:blank', '_blank');
                myWindow.document.write(allText);

                myWindow.document.close();
                myWindow.focus();
                myWindow.print();
                myWindow.close();
            }
        }
    }
    rawFile.send(null);
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I had to use a setTimeout() because the page would close before the printing was done and the printing service couldnt find the page content.

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