Hi team,
I'm currently trying to use an open-source JavaScript library in my OutSystems Web project and those external JavaScript code MUST be added to the end of <body> tag in html.
It seems that if I try to add JavaScript code to my application using the method shown in the picture attached, those code will be inserted into the <head> section automatically.
I have to give up developing on OutSystems if I can't use this JavaScript library so are there any option to put JS code just before the end of <body> section?
Thank you in advance.
Mofeng Zhang wrote:
Hello Zhang,
You can put your script in the layout section in order to make it work.
I also did it long back that worked for me. below image
This means all the HTML will be rendered first than this script. just try and let me know if it worked for you.
Regards,
Pankaj
Pankaj pant wrote:
It worked!
Thanks very much for your help.
Use expressions for inline javascripts.
Refer to : https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/JavaScript/Extend_Your_Web_Application_Using_JavaScript/Define_and_Run_JavaScript_Code#Unescaped_Expressions_Example
Unescaped_Expressions_Example section
Tushar Panpaliya wrote:
Thank you for your advice but I don't think I can insert something like this in this way...
Hi Mofeng,
Please try below approach -
function loadScript() { var scriptToAdd = document.createElement('script'); scriptToAdd.type = 'text/javascript'; scriptToAdd.src = 'your script';//add you external script here document.body.appendChild(scriptToAdd);}window.onload = loadScript;
Please add above code in WebScreen. This should fix issue.
Durgesh Rokade wrote:
This approach worked for me. but instead of using window.onload i added the direct function code as a javacript code under onRender screen method for my reactive web app.
can you attach the oml for me