Show URL in new tab

  1. 2 weeks ago

    Tony L

    Jan 8 Pre-Release Testers, Xojo Pro Hong Kong

    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?

  2. last week

    Michel B

    Jan 10 Pre-Release Testers, Xojo Pro

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

  3. Tony L

    Jan 10 Pre-Release Testers, Xojo Pro Hong Kong

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

  4. Derk J

    Jan 10 Pre-Release Testers, Xojo Pro
    ExecuteJavascript( “document.getElementById('yourLinkID').click();” )
    

    From your button action event

    Replace youLinkID with WebLink.ControlID

    It’s kinda hackish but should work

  5. Tim P

    Jan 10 Pre-Release Testers, Xojo Pro

    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.

  6. Tony L

    Jan 10 Pre-Release Testers, Xojo Pro Hong Kong

    @Derk J , should I put it this way?

    dim id as string = WebLink.ControlID
    ExecuteJavaScript ("document.getElementById('" + id + "').click();")

  7. Greg O

    Jan 10 Xojo Inc Somewhere near Raleigh, NC

    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.

  8. Michel B

    Jan 10 Pre-Release Testers, Xojo Pro

    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

  9. Tony L

    Jan 10 Pre-Release Testers, Xojo Pro Hong Kong

    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.

  10. Michel B

    Jan 11 Pre-Release Testers, Xojo Pro
    Edited last week

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

  11. Tony L

    Jan 11 Pre-Release Testers, Xojo Pro Hong Kong

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

  12. @Michel B Place a PageSource on the page, and put this in the source :
    <style> a { color: red; text-decoration: none; } a:hover { color: green; } a.visited { color: black; } </style>

    If you use style like this, ALL of your weblinks will have same look.

  13. Michel B

    Jan 11 Pre-Release Testers, Xojo Pro

    @AsisPatisahusiwa 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.

  14. Tim P

    Jan 11 Pre-Release Testers, Xojo Pro

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

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

  16. Michel B

    Jan 11 Pre-Release Testers, Xojo Pro

    @AsisPatisahusiwa 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.

or Sign Up to reply!