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

375
Vistas
Open browser print window without using a package ReactJS

I want to print my whole page on react js without using a package. Is there any way to do this, i found Window.print() which does not seem to work.

Just want to open the browser print window. The shortcut for that is Ctrl+P on chrome so there could be a possibe way to press ctrl+p onClick of a button maybe.

<div>
<h1> Hello World </h1>
<button onClick = {DoPrint}></button>
</div>

Edit : Code to do this would be

Should work on all browsers except for Firefox For Android

<button className="DoTest" onClick={window.print}></button>

Thanks

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

0

You could declare your page with an iframe:

<iframe id="idofyourpage" style="position: absolute; ..."></iframe>

And then print it with something like this:

var myPrint = document.getElementById("idofyourpage").contentWindow;
myPrint.focus();
myPrint.print();

Also remember that you might need to open the document and write some content to it depending of your functionality. However, I remember having used window.print() successfully, so you would also like to make sure you used it correctly, since it's an easier and cleaner way to get your page printed in a component.

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