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

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

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 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