Dashboards & Visualizations

including javascript in data > ui> alert > test.html , but javascript is not working

Explorer

under this folder structure

├───appserver
|----------------└───static
|--------------------------└───test.js
├───default
│----------└───data
│---------------------└───ui
│-------------------------------└───alerts
--------------------------------------------└───test.html

I am trying to include a JavaScript code or JavaScript file under "test.html" but it is not happening

<form class="form-horizontal form-complex" script="test.js">
    <input type="text" name="action.test.param.confgid" id="create_tests_confgid"   />
</form>

following code is written in test.js

$(document).ready(function(){
  alert("testing the alert ");
  });

Note : I am able to see the form on web interface of splunk but the java script code is not executing .

Can anyone help me to include the JavaScript code to specified code structure?

Regards,
Amit Vikram

Champion

It is not possible to use javascript in custom alert html code. The docs themselves don't say this explicitly, but you can refer to the comments below the appropriate documentation where SK8 asked the exact question.
Feel free to leave feedback on that page requesting clarification (using the "Was this topic useful?"-section at the bottom), the docs team is super awesome and will appreciate your input.

Explorer

Hi Jeffland,

Thank you for taking time to reply to my query.

I had read the article earlier which you suggested but it was ambiguous , under topic :Security Consideration they says:

"Except for a dynamic dropdown control, only static HTML markup should be used in the interface. Do not include scripts or other constructs that could put your system at risk."

by this line it sounds like it is possible but recommended not to use it.

As suggested by you , I have left my feedback on the article.

Regards,
Amit Vikram

0 Karma

Engager

Hi!

I also understand the Security Consideration, but have no other option than include a javascript code.
I want to enable HTML email formatting inside a text box with WYSIWYG javascript interface like CKEditor.

Who can advise a solution?

0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!