Is it possible to bring an Application-Level Window to front?

Hi,

I’m playing a bit with Application-Level Windows. In my app, I’m opening a new window by calling mainWin.open(new ExternalResource(myWin.getURL()), “_blank”); This works fine, but I would like to bring this window to front, if the user tries to open it again and the window is already opened.
Calling Window.bringToFront() doesn’t work, because the window has no parent. I did also tried some JavaScript code like “window.focus();” to get the window in front, but that doesn’t helped either.

Is there a possibilty to bring an Application-Level Window to front?

Any help is much appreciated

Andreas

There’s no API in Vaadin for that.

As far as I know, the possibility to do that depends greatly on the browser. For example, in Firefox you have the Preferences → Content → Enable JavaScript → Advanced → Raise or Lower Windows setting. It’s disabled by default, so you should assume that it’s disabled for practically everyone. Other browsers might not even have such a setting.

I guess the window.focus() JavaScript should do that if the setting is enabled.

Hi Marko,

I changed that setting, closed and started Firefox but the already opened windows didn’t came to front. :frowning: I also tried it on a colleagues pc/firefox with the same negative result.

Any other ideas?

Andreas

No, not really. The issue does not seem to be really Vaadin-related anyhow.

See if
http://stackoverflow.com/questions/3311293/javascript-bring-window-to-front-if-already-open-in-window-open
thread can give you help. Also look at the Related column of links.
As said, this is browser dependent: because some sites abused of the control of spawned windows to, for example, pop a window under the current browser so an ad appears when minimizing the latter, they restricted the possibilities of such manipulations, unless you unlock them (if possible!).

Now, you might want to consider using an in-browser dialog instead. I tend to see separate windows in Web applications as things of the past, favoring those using the browser’s page as the application screen. But it might not fit your use case.

Hi Philippe,

thanks for your comment. I did already read that thread and also many related other threads. So far, I couldn’t bring an existing window to the front. I read from many people that window.focus(); should do the trick, but for me it seems, that Vaadin is maybe not giving this script to the right window and/or I need to call it on the window variable that Vaadin is using internal.

Did someone managed it to get it working at least with Firefox?

Thanks

Andreas

Well, as I wrote, browser are now quite stubborn for such windows.
Actually, if I try the
Application-level window demo
in Firefox or Chrome, nothing happens when I click the button. Actually, Chrome 14 shows a discrete notification of a popup window being blocked (and a way to display it), but Firefox 7 shows nothing!
That’s another reason why, personally, I will remain away from this kind of window.
I hope you will find a solution to your problem.