Is it possible to use a <script> element in the HTML Element widget of Mendix?

0
I want to test if it's possible to add a very simple script-element to the 'HTML-element' widget. After a few tests I didn't succeed in adding a simple script-element. Other HTML-elements like <p>, <div> and <a> worked. So my question is: Is it possible to use a '<script>' element in the 'HTML Element' widget of Mendix?   The simple script I wanted to implement is: <script>document.getElementById("Text").innerHTML = "Hello Mendix!";</script>    If that script worked I wanted to implement a more extensive script: <button type="button" onclick="myFunction()">Upvote for Mendix!</button> <p id="Text">You've not upvoted Mendix yet :(</p> <script>function myFunction() {   document.getElementById("Text").innerHTML = "You've upvoted Mendix!";}</script>
asked
3 answers
0

You may be better looking at using the HTML / JavaScript Snippet widget instead in this case.

 

https://docs.mendix.com/appstore/widgets/html-javascript-snippet/

 

Good luck

answered
0

We're preparing for React and in the documantiation we read 'HTML and JavaScript snippets are not supported in Mendix's React client.'

 

So we have to move to the HTML Element, I tried placing an <script>-tag inside a <div> but the <script>-tag is not allowed.

 

We can't use a nanoflow because the script has to run before a user is logged in...

 

Has anyone a suggestion?

answered
0

I haven't tried it myself yet, but what if you whitelist the script tag in the advanced tab of the HTML widget?

{"ADD_TAGS":["script"]}

 

answered