JavaScript not executed or not visible

0
Hi, I’m the  HTML/JavaScript Snippet from the Marketplace in Mendix Studio 9.1.1 It’s placed in a container widget.   In the contents of the HTMLSnippet I pasted “<script type= “text/javascript” src = ...”> The javascript itself is working properly when I test it on jsfiddle.net but in Mendix I see nothing, just a blank page. Any idea how I can fix this? Thank you and best regards, Sascha
asked
7 answers
2

HTML just make a html, Javascript just execute java script. You can not put the script in HTML

Workable like this

answered
1

If you have several languages in your app, check that all languages have the same javascript. 

 

Also I dont believe you can add a source in that snippet, I was only able to run simple javascript.

If you need to add a library, (and therefore use the src = … functionnality), you have to add that library directly inside your index.html page (inside the theme folder)

answered
0

Did you try to refresh the page while having your developer console open in Chrome (can be opened using F12). This will probably give some more details about the error.

answered
0

the console log do not indicate any errors besides the “deprecated” entries:

answered
0

Hi Sascha, 

it could be, that your javascript snippet is executed, before the client has finished loading the entire page. 
Best use mx.addOnload() to execute your script, after the client has finished loading. You can find some more information about it here: https://apidocs.rnd.mendix.com/9/client/mx.html

And one more thing: Your HTML/Javascript is set to HTML. Set it to Javascript and try again :)

answered
0

Hi Alex,

If I switch over to Javascript the page shows an error: “Error while evaluating javascript input: SyntaxError: Unexpected token '<'”

Regarding mx.addOnload() can you please refer to a how-to as I’m pretty new to Mendix.

Thanks,
Sascha

answered
0

Hi Sascha, 
I would suggest you create a custom/pluggable widget for that. HTML/JavaScript widget has only some limited capabilities and for your usecase I think it is not the best solution. Have a look at this learning path to get you started https://academy.mendix.com/link/path/108/Build-a-Pluggable-Widget

Nevertheless I must admit, that this is not a simple solution. 

answered