andyhill Posted April 14, 2023 Share Posted April 14, 2023 uniSession.AddJS('test();'); // FAILS test() not defined If the script is loaded in the IDE it works ! There is lots of talk on the forum dealing with this problem but no clear answer that I can see - please advise - thanks Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 14, 2023 Share Posted April 14, 2023 Hello, In short, create a global function. Quote Link to comment Share on other sites More sharing options...
Ron Posted April 15, 2023 Share Posted April 15, 2023 If the function is not defined, it is not loaded. Put the script in a textfile and load it, and it will work despite having commented lines. Or terminate those lines. Dynamically loading a script as strings in code, including commented lines (starting with //) and not terminating them with CR/LF (chr(13)+chr(10)) will disable everything after the //, and functions will then not be loaded. So if it works, it is loaded. If it does not work, it is not loaded. If part of the script is "lost" due to commented lines, you will not get a warning in the console as that part is not loaded. The browser just believes you have disabled the rest of the script. Checking for "undefined" or running the function, will tell you if it is loaded or not. 'function updateView()'+ '{'+ ' //canvas.width = MainForm.HTMLFrame.getWidth();'+ chr(13)+chr(10)+ ' //canvas.height = MainForm.HTMLFrame.getHeight(); '+ chr(13)+chr(10)+ ' canvas.width = 600;'+ ' canvas.height = 360;'+ ' drawScreen();'+ '}'+ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.