Browser Window Opener

Hi,

I am using Browser Window Opener in my project.

Is there any possibility to set focus (Restore window size and bring it on top of other browser windows) to newly opened browser window on button click event in following cases:

  1. When newly opened browser window is minimized
  2. When newly opened browser window is behind other browser windows.

Also I need close newly opened browser window when my main application browser window is closed.

Regards,
Kunal Patil

So you want to bring a window you opened using BrowserWindowOpener and then either minized or put other windows on top back in the foreground and also close when the Main App closes. That is not possible as the other window is not linked to the Application. Things like having windows in the Foreground is controlled by the OS which can’t be controlled using Vaadin or any Web Framework (at least i hope there is none).

You could pack your content into Vaadin Window Components containing a Browser Embedded Component. This way these Windows are still part of your Application and can be fully controlled.

The JavaScript
window.open
function returns a handle to the opened window that you can later use to bring it to front by calling
.focus()
on it. Unfortunately, the BrowserWindowOpener does not store the handle nor does it expose it to the server side, and finding it out afterwards is not possible in JavaScript. This might be a nice new feature in some future Vaadin version, but currently you’d have to implement it yourself.

Nevermind then. I learned something today. Thanks Johannes.

Yeah, I learned that today as well :smiley: I’m not sure whether all browsers actually let you do that, though.

hi, i hope this will be usefull for you.

[font=courier new]

Page.getCurrent().open(url,target);

[/font]

if target > “_self” it will open current browser page
if target > “_blank” will open new tab or new browser like pop-up

(in vaadin 7)

Okay :smiley:
I was curious to see if it would really work on all browsers so i made a small HTML + JavaScript test like this:

<html>
<head>
<meta charset="ISO-8859-1">
<script type="text/javascript">
var SubWindow;
function openwindow(){
    SubWindow = window.open("https://vaadin.com/home", "SubWindow");
}

function bringtofront(){
    SubWindow.focus();
}
</script>
</head>
<body>
<input type="button" value="open" onclick="openwindow()"/>
<input type="button" value="focus" onclick="bringtofront()"/> 
</body>
</html>

and tested it with some of the browsers i had installed and it seems to work perfectly with Firefox 26 and Chrome 32 but IE9 displayed an error when trying to call SubWindow.focus() saying that the object is null…Weird

PS: Probably because of
this