Dashboards & Visualizations

Why does the print dialog launches unexpectedly after printing?

davefarmersplun
New Member

I am a newbie to Splunk, and am doing maintenance on some legacy code and I noticed that whenever I refresh the dashboard after having printed, the print dialog will re-launch unexpectedly.

The code for printing hooks the dashboard click event for the Splunk print icon:

    $("#dashboard").on("click", "#print", function(e){

Then the click-event code creates a window, populates it with the contents that will be printed, and then launches the print dialog:

                    var win = window.open("", "_blank");
                    win.document.write($("head").html());

                    //create css element
                    var css = document.createElement("STYLE");
                    css.appendChild(document.createTextNode('th{background-color:#e6e6e6;} tr:nth-child(odd){background-color:#d5e2e9;} td{border: 1px solid #e8eef4;padding: 5px;}'));
                    win.document.write(css.outerHTML);

                    //create table and 
                    win.document.write(str.outerHTML);
                    win.document.close();
                    win.print();

So the question is "why does the print dialog get relaunched?. Is there an issue with tokens? Note that the click event code is not re-entered for this scenario. The print dialog (which becomes a new tab) is recreated, but not by the code.

I hope you can help.

Tags (3)
0 Karma

davefarmersplun
New Member

The version of Splunk used is 6.5.2.

Additionally, the dialog is re-displayed without entering the code that launches it. In other words, the dashboard "print" click is not fired.

0 Karma

niketn
Legend

@davefarmersplunk, which version of Splunk are you using? Under the Dashboard Export option, you should also have a built in option to Print the dashboard without having to depend on custom JavaScript.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

.conf25 Registration is OPEN!

Ready. Set. Splunk! Your favorite Splunk user event is back and better than ever. Get ready for more technical ...

Detecting Cross-Channel Fraud with Splunk

This article is the final installment in our three-part series exploring fraud detection techniques using ...

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...