Show URL in new tab

Hi all,

I know there were discussions on this topic, but just can’t help my problem. I understand that I cannot open a URL in a new tab through a button action but an WebLink. However, for the consistency of the UI design, I would like to do:

  1. set a hidden WebLink in the window with me.URL and me.Target set
  2. when then user press a WebButton, program “auto” press the WebLink, so that the target URL shows correctly in a new tab

What can I do?

Use a weblink disguised as a button, per previous discussions, using a webstyle.

I tried, but WebLink has an underline as default, it doesn’t match like a button


ExecuteJavascript( “document.getElementById('yourLinkID').click();” )

From your button action event

Replace youLinkID with WebLink.ControlID

It’s kinda hackish but should work

Should work, or tested and does? That seems to me like a huge security hole if you can use javascript to click links, especially ones that open new windows or tabs.

@Derk Jochems , should I put it this way?

dim id as string = WebLink.ControlID
ExecuteJavaScript (“document.getElementById(’” + id + “’).click();”)

I doubt that’s going to work. Over the last few years, browsers have added pop up blockers which prevent JavaScript from opening a new window unless executed directly from a user mouse event.

Indeed click() no longer works to open a new window/tab.

The best bet is to use a link styled as a button.

Search is your friend : https://forum.xojo.com/34065-weblink-style-not-respected/0

What about if I can detect if the browser is set allow popup or not so my app can remind the user to change the setting? As users may not aware the little message box from the browser like Chrome.

Tony, please read the link I posted. No need to embark in complexity.

Thanks all, will try again with Michel’s advice.

[quote=278314:@Michel Bujardet]
Place a PageSource on the page, and put this in the source :

[code]

a { color: red; text-decoration: none; } a:hover { color: green; } a.visited { color: black; }

[/code][/quote]
If you use style like this, ALL of your weblinks will have same look.

Indeed. It is relatively easy to use JavaScript to do it for only one link.

Or define a style class, and apply it to only links that need to look like buttons.

I prefer using WebControlWrapper, more easy, just a few code.

Not everybody is able to use WebSDK. Sometimes it is necessary to help people who have less skills.