Application still shown in browser?


I’m looking for a way to check if my application or it’s window is still being displayed in a browser.

As quoted in this thread, the closelistener is triggered by closing the browsertab or by hitting the refresh button.



The isVisible() method keeps telling me it is still visible while I have closed my browser. If someone could find a way to tell if the application is still being displayed in a browser, it would help a lot.

private class CloseListener implements Window.CloseListener {

		public void windowClose(CloseEvent e) {
			Timer timer = new Timer();
			timer.schedule(new TimerTask(){

				public void run() {

				}}, 10000);


I’m not aware of any way of knowing whether the application is still displayed. Window.isVisible() only reflects the state that has been set from server-side code.

Only relying on a CloseListener does has two problems: The application might still be open after the close event because the event is also triggered when a download is initiated as the browser only realizes that it was a download after already starting to load the URL. The other problem is that e.g. Opera doesn’t send the javascript even that triggers the CloseListener. If there is currently no network connection, no browser is able to send the information to the server even though the network connection is restored later.

The best you could do would probably be to use e.g. the Refresher add-on and consider the application closed if there has been a certain time without any request from the Refresher. This approach might however also fail e.g. if the user is temporarily without a network connection.

Hi Leif,

I tried the refresher with some demo source code and the results look promising :slight_smile:

Now I’m going to implement it in my application.