Dashboards & Visualizations

How to open a Javascript drilldown link in a new browser tab?

wcooper003
Communicator

I have a drilldown link coded in Javascript that opens the link from a dataset field value (field 'link' in example below):

// RequireJS dependency handling
require (["splunkjs/mvc",
         "splunkjs/mvc/simplexml/ready!"], function (mvc)
{

    mvc.Components.get('table_core').getVisualization(function(tableView){
        tableView.on("click:cell", drilldown);
    });


   // Define a drilldown function that can be used by multiple click event handlers
   function drilldown (event) {
    event.preventDefault();
       window.location=event.data["row.link"];
   }
});

I want to have that link open in a new tab. How could I do this through the Javascript?

0 Karma
1 Solution

bmacias84
Champion

Nothing the author of a script or dashboard will allow opening a tab instead of a window. This is a user preference.

To open a new window use:

window.open(url);

Though you can open a new window if a tab is defined with come css with target-new, but i believe its deprecated in most browsers.

css3-hyperlinks-20040224/#target-new

View solution in original post

bmacias84
Champion

Nothing the author of a script or dashboard will allow opening a tab instead of a window. This is a user preference.

To open a new window use:

window.open(url);

Though you can open a new window if a tab is defined with come css with target-new, but i believe its deprecated in most browsers.

css3-hyperlinks-20040224/#target-new

wcooper003
Communicator

Thanks for the comment. Where would I put that in my Javascript? Would I replace my window.location=event.data["row.link"] with window.open(event.data["row.link"])?

0 Karma

bmacias84
Champion

Sure if event.data["row.link"] contains the the url you want to open.

0 Karma

wcooper003
Communicator

Hmm that unfortunately didn't work - it just caused the drilldown to default to the default Splunk drilldown (opening search), not using the url. The URL that event.data["row.link"] uses is relative - it starts with "/app/....". Does it need to be an absolute url path?

0 Karma

bmacias84
Champion

url has to be absolute. example: https://www.google.com

0 Karma

wcooper003
Communicator

Excellent thanks, that worked. I have some links on the page that I want to open up in same tab, but others I want to open up into different tabs. So I just created two javascript files that do things differently, so working like a champ now.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...