For a web application, how do I close all associated browser windows when a timeout session / user subscribes?

Let's say a user has opened my web application in many different browser windows. After a while, it will quit the program / quit the application.

I want to close all associated browser windows. How can we deal with this?

(I think GMAIL does it)

+1


source to share


3 answers


If you maintain links to any child windows, you can use window.close () in combination with setTimeout () .



As a side note, you should probably be careful when closing user windows, as this can potentially cause a bad user experience. Imagine I open my banking site to view transactions for an account so I can clear / reconcile them. But in the middle, I run off to grab lunch or something. When I return, I find that all my windows are closed and I have to rewrite, although I didn't need to, because I was just looking at a relatively static list of data. Or worse, if the window doesn't close properly, I might find that my browser is completely closed, which is definitely a bad experience.

+2


source


not to do. As far as the typical user is concerned, your website does not have the right to close user windows and they will NOT HAVE your site if you try. If you believe your website relies on being able to close the user's browser to function properly, you are doing it wrong.



In addition, you cannot count on the success of your attempt to close user windows or similar actions. So take the time to get your website to work properly, no matter what the user is doing in the browser. It is also easier.

+1


source


Write a script that, when focus is delivered to the window (for your application), checks if the session is actually valid. If not, send a command to close the window.

0


source







All Articles