Add search options to the search results page

Your Interact intranet is very often the main site your users use, and with features such as the application links bar, is often seen as a gateway or jumping off point to other systems. This is very true in the case of search. Interact has a number of integrations for search including Sharepoint and Google Drive, but what options are there if there is no integrations available?

In this case, the best solution is to add a new 'tab' to the search results page, allowing a user to click on that tab to open the target system in a new window, and pass through the search term. This means that your users can perform a search within the intranet, and from there perform the same search in a different system, for example Confluence.

The javascript below can be added to the developer framework Masterpage Javascript in your intranet - once saved, when a user performs a new search, they'll see a tab (in this example called 'ServiceNow') which will open a new window to the specified URL. The example below is for a generic service-now instance so will need adjusting to your needs.

This can be used to add as many tabs as you want

// Set some variables for the servicenow instance.
var servicenowDomain = "www.service-now.com/search_sp?&q=";

function searchservicenow() {
    // Open a new window to the specified URL and add the search term.
    var searchTerm = $('input[type=search]')[0].value;
    var url = "https://" + servicenowDomain + encodeURI(searchTerm) ;
    window.open(url, '_blank').focus();
}

window.setTimeout(function () {
  // build the HTML for the tab
    var servicenow = '<li><a href="javascript:void(0)" onclick="searchservicenow()" role="tab" aria-selected="false" class="">ServiceNow <span class="icon is-normal"><i class="is-normal ii ii-external-link"></i></span><span class="sr-only">(opens in an new tab)</span></a></li>';
    
  // Add this tab after the 'Intranet' results tab
    $('#directoryTabs li:nth-child(1)').after(servicenow);
}, 500);