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!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...