My problem is that when I create a script tag trough javascript
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
document.getElementById("fastexe").appendChild (script);
(the div parent of the script is before this script), and I insert a function in it like so
script.innerHTML = "function in_my_script(){ \n";
script.innerHTML += "alert('test'); \n }";
when I try to call my function (function_in_my_script) through the console or even like this:
script.innerHTML += "\n function_in_my_script();";
I get a function not defined error, for apparently no reason. I tried with different function names, nothing inside of the function and different alerts in the function but nothing changed the result.
I don't understand why the function stays undefined. Thanks for your help.
innerHTMLon script elementsin_my_script, notfunction_in_my_script. If this is just example code, please edit your question.