Trying to open URL in new tab - target _blank not working
Question

I am trying to open an external URL in a new browser tab.


The Service Studio version is 11.6.26 Build 9940


I believe it is coded properly, but it still displays the screen in the current tab.


I have tried the target="_blank" extended property and adding it to the Javascript Open URL.


Please let me know how to do this.   Thank you for your advice.


This is what is generated using the Button and the Link widgets :


#1 using a button widget:


<input target="_blank"

       onclick="window.location.href='https://some-URL','_blank'; return false;"

       type="submit"

       name="wt10$wt37"

       value="view order"

       id="wt10_wt37"

       tabindex="0"

       class="Button btn-small

       ThemeGrid_MarginGutter">



( I also notice this didn't end with />  )    



#2 using a link widget:


<a id="wt10_wt92"

   tabindex="0"

   target="_blank"

   onclick="OsAjax(arguments[0] || window.event,'wt10_wt92','wt10$wt92','','__OSVSTATE,',''); return false;"

   href="#">

   <span id="wt10_wtdisplayOrderNumber"

         class="btn btn-small background-blue" style="font-weight: bold;">

         {the-order-number}

   </span>

</a>


Solution

I tried the Navigate and numerous variations. 

It does work this way: 

onclick="window.open('https://www.w3schools.com/tags/att_button_type.asp', '_blank');"

Hello Chris,


In the button don't put "_blank" in the URL. Regarding the link, the Method is Ajax Submit and that's wrong, change it to Navigate.


With the best regards,

Gonçalo

mvp_badge
MVP

You should change method property to "Navidate" of your link widget. Then it will work.

Solution

I tried the Navigate and numerous variations. 

It does work this way: 

onclick="window.open('https://www.w3schools.com/tags/att_button_type.asp', '_blank');"

mvp_badge
MVP

Hi Chris,

Good to see that you were able to resolve your issue with this script, it will obviously work. 

But I am not able to understand why setting link's method property to Navigate and then using target="_blank" not working for you. 

I understand that this will not work for button but for link this is the standard way and should work in any case.

Nikhil Gaur wrote:

Hi Chris,

Good to see that you were able to resolve your issue with this script, it will obviously work. 

But I am not able to understand why setting link's method property to Navigate and then using target="_blank" not working for you. 

I understand that this will not work for button but for link this is the standard way and should work in any case.

The only thing I could think of is maybe there is something taking precedence in my company's custom themes (set up by Outsystems).


Champion

Chris Kraack wrote:

I am trying to open an external URL in a new browser tab.


The Service Studio version is 11.6.26 Build 9940


I believe it is coded properly, but it still displays the screen in the current tab.


I have tried the target="_blank" extended property and adding it to the Javascript Open URL.


Please let me know how to do this.   Thank you for your advice.


This is what is generated using the Button and the Link widgets :


#1 using a button widget:


<input target="_blank"

       onclick="window.location.href='https://some-URL','_blank'; return false;"

       type="submit"

       name="wt10$wt37"

       value="view order"

       id="wt10_wt37"

       tabindex="0"

       class="Button btn-small

       ThemeGrid_MarginGutter">



( I also notice this didn't end with />  )    



#2 using a link widget:


<a id="wt10_wt92"

   tabindex="0"

   target="_blank"

   onclick="OsAjax(arguments[0] || window.event,'wt10_wt92','wt10$wt92','','__OSVSTATE,',''); return false;"

   href="#">

   <span id="wt10_wtdisplayOrderNumber"

         class="btn btn-small background-blue" style="font-weight: bold;">

         {the-order-number}

   </span>

</a>



Hi Chris,

weather your are aware or not the target=_blank does't work with button. so in this case what you can do is style a link that  look like button.

with that link you can use target=_blank;


Best regards,

Pankaj Pant

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