Community
Participate
Working Groups
ExternalBrowser#open currently *ALWAYS* opens as a pop up windows. This has several drawebacks. Most notably the operation is blocked by a pop-up blocker (tested in FF, Chrome). This is somehow related to Bug #267831. In order to allow opening in new browser tabs or windows the the window name "_blank" (or none at all) must be used when calling JavaScript. For details see here: http://www.webreference.com/js/tutorial1/open.html
I did some testing today about this issue. Here are the results in all browsers - FF, IE, Safari, Chrome, Opera: 1. Window name is not important - "_blank" or not, a new window/tab is opened. 2. Popup blocker ALWAYS (if not disabled by the user) blocks the new opened tab/window - created by window.open. 3. Opening a new window or tab is controlled by browser user preferences. For me the conclusion is that, everything opened by window.open (javascript) is treated as popup and potentially blocked by browser Popup Blocker. Opening a window/tab by user interaction (click on a link for example) is a different story.
I would like to add to comment #1 that the window name in window.open() controls whether a new window or tab is opened or not. If there is already a window/tab with the same name then this window is reused. The given URL is loaded in this window, replacing the former content. If there is no window open with the name then a new window is opened. To my knowledge, the window name "_blank" has the special meaning to always open a *new* window/tab.
I wonder if there is a reliable way for RAP applications to open new tabs/windows from a push button what doesn't get blocked by popup blockers? Looks like the only option is a hyperlink widget?
Maybe another easy option is a Browser widget with HTML page that renders a simple HTML button. Here are some examples http://www.pageresource.com/jscript/jwinopen.htm
(In reply to comment #3) > I wonder if there is a reliable way for RAP applications to open new > tabs/windows from a push button what doesn't get blocked by popup blockers? > > Looks like the only option is a hyperlink widget? Right now you can use the Browser widget to emulate what you want. Take a Browser widget and call its setText() method with a string like this: <a href="url-new-document" target="window-name/_blank/...">Click Me</a> What you get is a link to the new document within your application. Alternatively you may replace the <a> tag with an <input type=button> and provide some Javascript to react when it is selected.
Created attachment 188499 [details] Browser widget vs. FormText I tried using the Browser widget. Unfortunately, it doesn't fly because of the different default formatting. Can't the FormText be "enhanced" to implicitly support http:// https:// links?
Gunnar, I don't understand your request. Could you provide a small FormText snippet to show where you need these schemes?
Here is an example: final FormText welcomeText = toolkit.createFormText(client, false); welcomeText.setText("<text><p>Some text with a link to our <a href=\"http://www.eclipse.org/gyrex/\" alt=\"Open the Gyrex blog.\">blog</a>.</p></text>", true, true); As you can see, the text contains a vanilla HTML link. In order to trigger it I need to register a hyperlink listener. welcomeText.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(final HyperlinkEvent e) { final Object href = e.getHref(); if ((href instanceof String) && (StringUtils.startsWith((String) href, "http://") || StringUtils.startsWith((String) href, "https://"))) { ExternalBrowser.open("_blank", (String) href, 0); } } }); Unfortunately, that always triggers the pop-up blocker.
(In reply to comment #6) > Created attachment 188499 [details] > Browser widget vs. FormText > > I tried using the Browser widget. Unfortunately, it doesn't fly because of the > different default formatting. Couldn't the formatting be fixed with some inline CSS?
(In reply to comment #9) > Couldn't the formatting be fixed with some inline CSS? It should be the same CSS that is used by FormText. Do you have a hint where this is used? Maybe it's easy accessible.
(In reply to comment #10) > (In reply to comment #9) > > Couldn't the formatting be fixed with some inline CSS? > > It should be the same CSS that is used by FormText. Do you have a hint where > this is used? Maybe it's easy accessible. This is the default CSS for the FormText widget: FormText { color: black; background-color: rgb( 255, 255, 255 ); font: 11px 'Segoe UI', Corbel, Calibri, Tahoma, 'Lucida Sans Unicode', sans-serif; border: none; } The snippet was taken from FromText.default.css in package org.eclipse.ui.forms.internal.widgets.formtextkit in plug-in org.eclipse.rap.ui.forms
With the bug 355861 fixed, we can now add a markup to the Label including HTML hyperlinks. The hyperlink styling can be controlled by the Label styling (font, background color...) or inline style attribute of the <a> tag. Gunnar, does it fit your needs? Can we close it as obsolete?
(In reply to comment #12) > Gunnar, does it fit your needs? Can we close it as obsolete? Yes. I saw it working on Ralf's machine yesterday!
(In reply to comment #13) > Yes. I saw it working on Ralf's machine yesterday! Fixed by adding markup support for Label (bug bug 355861).