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

105
Vistas
other option beside document.body.innerHTML

this is my code

  const printDiv = () => {
    const printContents = document.getElementById('id').innerHTML;
    const originalContents = document.body.innerHTML;
    document.body.innerHTML = printContents;
    window.print();
    document.body.innerHTML = originalContents;

    return false;
  };

i know when i using innerHTML gives me a string representation of the HTML within an element so i can't handle button or something like that.

actually, i can handle it with reload, but what is the best way? is there any option without reload which make me back to the same page?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

const printContents = document.getElementById('id')
const win = window.open();
win.document.title ="some title";
win.document.body.innerHTML = printContents.innerHTML;

/* if content contains images that needs loading*/
const images = win.document.getElementsByTagName('img');
/*wait for them to load*/

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