Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Can't manage to open a new tab with window.open()
I'm trying to open an URL from a leaf of a Tree. As Tree can only contain Items and not Links, I've added a "link" property on my items, and when the item selection event is caught, i'm launching the following code:
String url= (String) selectedItem.getItemProperty("link").getValue();
this.getWindow().open(new ExternalResource(url), "_blank");
On every browser I tested, this code NEVER opens a new tab but always create a new window. When removing the 2nd parameter "_blank", the url is opened in the current window, which is also not what I want :-(
How can I open an URL in a new tab with this method?
Thanks a lot,
Yannick Sonic: How can I open an URL in a new tab with this method?
Sorry to be the messenger. But welcome to the forums anyhow!
Hi, thanks for your answer
The thing is I know there is no way to "force" opening a tab instead of a new window, the thing is even if the browser is set to open each link in a tab, the url will still open in the new window...!
And as this is not a Link object, this is not recognized as an actual link in the browser, so there is no default "middle click on a link" action that will be recognized by the browser. On this Item, I would have to implement "middle click" or "ctrl+click" event recognition to still trigger... a window.open()
So to be more accurate, the question is "how to make window.open() open a new tab when the browser is configured to open all new links in tabs"?
Same problem here, I would like to open a static external URL from a menu and open that as a new page/tab.