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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...