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

78
Vistas
Close Tab after file download using Javascript/React JS

New tab gets opened if i want to download a file. In the below code i have closed the new tab after 10 sec. but the time should not be hardcoded. it should be the time taken for file download. Any suggestion how to calculate time taken for file download?

<a  href='' onClick={(e)=>activeTab(e,link) }>{filename} </a>

  const activeTab=(e,url)=> {
   const newWindow = window.open(url, '_blank');
   var startTime = (new Date().getTime());
   var endTime;
    if (newWindow) {
      //newWindow.opener =null
      if(newWindow.opener){
        setTimeout ( function () {
            newWindow.close ();
       }, 10000
      )
    }
    endTime = new Date().getTime()
  }
    e.preventDefault ();
    e.stopPropagation ();
  }

Please suggest me for any solutions.

about 4 years ago · Juan Pablo Isaza
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