30
Views
4
Comments
open in new tab does not work for link with onclick set for ClientAction
Application Type
Reactive

open in new tab does not work for link with onclick set for ClientAction 
ClientAction uses ServerAction to get URL
same tab is opened causing poor UX UI

target : "_blank" does not work 



2021-11-12 04-59-31
Manikandan Sambasivam

In OutSystems, when using a link with an onclick event set for a ClientAction that eventually retrieves a URL from a ServerAction and tries to open it in a new tab, you might encounter issues with the target="_blank" not working as expected. This is because opening a new tab generally requires immediate action in response to a user event, and using ClientActions with asynchronous ServerActions can disrupt this flow.

Steps to Open a Link in a New Tab

  1. Create a ServerAction to Get the URL: Ensure you have a ServerAction that retrieves the URL you want to open in a new tab.

  2. Create a ClientAction to Handle the Logic:

    • The ClientAction will call the ServerAction to get the URL.
    • Once the URL is retrieved, the ClientAction will use JavaScript to open the URL in a new tab.
  3. Set Up the Link with the OnClick Event:

    • The link will trigger the ClientAction.
    • The ClientAction will handle the URL retrieval and open the link in a new tab.
2024-04-19 08-26-30
syerasyl


did not get 3rd step of ur guide, plz explain in more detail

2019-01-07 16-04-16
Siya
 
MVP

Add a DataAction on the screen to return the URL (e.g., GetURL.URL), then set the link's OnClick event to RedirectToURL and assign the URL as GetURL.URL.  ( Note : If you want to open in new tab by default set attributes as target : "_blank" )

2024-05-18 23-16-58
Simone Lopes

Hello, 

The problem occurs because the property "target" add blank in a span, not in the default link, but you can try this: 


1- add a client action with a URL parameter, call this action on click button

2- In the client action, add a JS script with the code below:

window.open($parameters.URL, '_blank');


I hope this can be helpfull

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.