I have a function in my Vaadin application where I open up a native browser window. I would like the application logout method to detect if that window is still open, and if it is, then close it. I thought the following might work, but doesn’t seem to have any effect:
Thanks for the pointer, I did some searching (via Google) and it appears to be more complicated than that. I’ve found several examples of JavaScript that will supposedly close another window, I’ve not had any success yet. So, I’m still looking.
You can close another window only if the window that calls otherwindow.close() has opened that window. Otherwise it does not work. In practice there is no guarantee on who has opened the window (imagine what happens when one closes the original main window) and any approach on trying to close these other windows is doomed to be seen as unreliable. If I remember correctly - there is even some variation between browsers.
(Vaadin did in fact include automatic closing and updating browser windows in version 3. This feature was later removed as we could not make it reliable for above reasons).
If you really would like to do this reliably, enable polling or push for each window and have them close themselves by calling executeJavaScript(“window.close();”) in the window to be closed.
This doesn’t work in modern Chrome (at least) due to security checks. The message in the debug console is:
Has there been any progress in recent Vaadin releases?
I’d like to be able to close “child windows” (I don’t mean sub-windows in the Vaadin “Window” sense, but rather in terms of native tabs/windows that were opened off the main window) on logout, etc.
I’m also looking for such a feature. Cloaisng all (logged in to our vaadin app) browser tab. I tried the same with the javascript as follows.
function closeWindow() {
var win = window.open(location, '_self');
win.close();
}
This is working on IE and Safari. And enabling the following property “dom.allow_scripts_to_close_windows;true”, it’s working on Firefox too. But the same is not working on Chrome and Opera. Is there any suggestion or a solution for this issue?