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
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.
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
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?
@quzen , I have a similar use case. Would like to allow users to format an HTML email message body, and need to minify and escape the HTML before passing as a parameter. Did you find a solution?
Hello @JTG !
I tried different ways to include javascript into Alert HTML, even asked that question to Documentation team.
But in the end I haven't found a way to do that. Apparently it's just not allowed by the application.
What I finally did is created my own Send Formatted Email addon which allows:
Configured alert trigger looks like this:
And an email example looks like this: