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

331
Vistas
How do I close a browser tab after running Python?

I have a web application where I need to open a new tab, run some Python, then close the tab. The reason I'm doing it this way rather than redirecting to the previous page is because the users would like it to retain the search filters.

I'm using Firefox to test it, and I'm aware that Javascript won't close the window if it wasn't opened with Javascript; apparently the same is true if I run any Python functions, because the "cancel" button on the same tab works without any problems.

Things I have tried:

  1. using HttpResponseRedirect to redirect to a new page with a "close" button that runs a Javascript function to close - the function is definitely being called (I can prove this with a window.alert) but the "window.close()" line gets ignored (no errors or anything, it simply does nothing).
  2. using HttpResponse to return 'window.close()' in the Python code - again, if I change it to a window.alert, I can prove the script is running, but again, the 'window.close()' is completely ignored.
  3. adding a window.close() function to the Submit button - this only works if I run it before the "submit", in which case the tab will close, but the "submit" will not happen.

Is there any workaround for this? Making users manually close the new tab with the X button just feels like such an obnoxious way to do it, and this feels like it should be so simple to do.

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