Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Estoy tratando de cerrar la ventana después de ejecutar un código pero la ventana no se cierra, probé window.close(); y cerca(); sigue sin funcionar

//cerrar la sección de la ventana es el problema, simplemente no cerrará la pestaña actual. Solo estoy ejecutando un código para descargar un archivo y luego requiero que la pestaña se cierre automáticamente como si nada hubiera pasado para mejorar la UX. Pero ventana.cerrar(); y cerca(); no está trabajando. Intenté muchas cosas encontradas en Internet que aún no funcionan. ¿Qué pasa con mi código?

 var url_string = window.location; //window.location.href var url = new URL(url_string); var file = url.searchParams.get("file"); var dFile = file; function onLoad() { if (dFile !== null) { var hiddenElement = document.createElement('a'); // Download hiddenElement.href = `${dFile}`; hiddenElement.target = '_blank'; hiddenElement.download = `${dFile}`; hiddenElement.click(); //Close Window var win = window.open("about:blank", "_self"); win.close(); } else { } } //Set The value of the File being Downloaded if (dFile !== null) { var SetFile = document.getElementById('xdFile') SetFile.innerHTML = "Downloading" + " " + dFile + " " + "now" }

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!