Open links to external websites in new window

walshy
Giga Expert

I have links that only open in the current window. I need them to open in a new window or tab. 

find_real_file.png

The ability to use the target field in the dictionary is gone, so I cannot use _blank there anymore. 

What are my options to getting this to open in a new window? 

Do I need to script it? If so where, I'm a little lost after googling everywhere for something I thought would be relatively simple... 

Ta. 

 

 

1 ACCEPTED SOLUTION

walshy
Giga Expert

This got solved here:

https://community.servicenow.com/community?id=community_question&sys_id=a6b2ca9bdb98db445322f4621f961989

 

basically I needed help finding where to put the target="_blank" for the href in the widget html. 

View solution in original post

4 REPLIES 4

Vikram3
Giga Guru

Hi Walshy,

there is not OOB way i could find.

 

follow below steps.

 

1)on menu item form create a new field(type true/false). like shown in below image.

find_real_file.png

check the new window(custom field) checkbox for links that u want to open in new window.

 

2) go to Angular ng-template(sp_ng_template.list) table. open record with id "menuTemplate".

 

replace first line with below two lines.

 

<a ng-if="item.items.length == 0 && !item.scriptedItems && !item.u_new_window" ng-href="{{item.href}}">{{ item.label }}</a>

<a ng-if="item.items.length == 0 && !item.scriptedItems && item.u_new_window" ng-href="{{item.href}}" target="_blank">{{ item.label }}</a>

like shown in below image.

find_real_file.png

Thanks for that Vikram,

 

Just quickly though, will that load the link in the variable URL I have, my brain is trying to tell me your set up would only load google but that is just nuts. 

I am assuming just following through your instructions will allow that field to be modified and then saved. Thus the new link will then be able to be opened in a new window. 

Whatever link you are providing in the field it'll be opened in a new window. 

walshy
Giga Expert

This got solved here:

https://community.servicenow.com/community?id=community_question&sys_id=a6b2ca9bdb98db445322f4621f961989

 

basically I needed help finding where to put the target="_blank" for the href in the widget html.