We are launching a Browser from our Python back-end code. This opens a 3rd party's URL , where the user needs to submit a form. After submitting the form , the browser instance should close automatically. We tried from Python's side but it is not possible to manage the state from back-end. Can we write some Javascript wrapper at front end to handle this?
Asked
Active
Viewed 255 times
1
-
1see [this](https://stackoverflow.com/questions/57854/how-can-i-close-a-browser-window-without-receiving-the-do-you-want-to-close-thi) – Tushar Walzade Feb 28 '19 at 10:39
-
try using `window.close();` in client side – Shibon Feb 28 '19 at 10:41
-
1Possible duplicate of [How can I close a browser window without receiving the "Do you want to close this window" prompt?](https://stackoverflow.com/questions/57854/how-can-i-close-a-browser-window-without-receiving-the-do-you-want-to-close-thi) – str Feb 28 '19 at 10:41
2 Answers
2
You can't.
Javascript can't close the browser from inside or it will be tricky

Tristan De Oliveira
- 800
- 4
- 12
-
Javascript can't close the browser ??? -- you can close a browser using `window.close();` – Shibon Feb 28 '19 at 10:44
-
0
Unfortunatly, if you don't have access to the 3rd party js code or an API informing you that request has been submitted, you can't even know when the user has submitted the request.
Switching on window.close(), if your application is opening only one window, you can use the:
window.close()
method. This method will close the current window. So, if you have only one opened window with Chrome (for example), the browser will be closed.
If you have multiple windows opened, only the window where the function is executed will be closed.

Dave
- 1,912
- 4
- 16
- 34
-
But when will I execute window.close(). How will it know my request has been submitted ? – Santosh Pashupati Feb 28 '19 at 10:56
-
if you don't have access to the 3rd party js code or an API informing you that request has been submitted, you can't even know when the user has submitted the request. – Dave Feb 28 '19 at 10:59