In my index.html file (before closing body tag), I want a function to self-invoke itself when the page is loaded. However, I am having issues when the function (here, setUp) is defined in an external file.
If I copy-paste the setUp function in Index.html then everything works as expected.
I am new to JS: am I incorrectly linking script file? Thanks!
Index.html
<script src="Code.gs">
window.onload=setUp;
</script>
Code.gs
function setUp() {
dateHelper_();
}
If my understanding is correct, how about this modification? The flow of this modified script is as follows.
google.script.runis run andsetUp()of Google Apps Script is run.setUp()is finished,"ok"fromsetUp()is returned and the returned value is shown usingconsole.log()atwithSuccessHandler().Done: okat the console of browser.Modified script:
Please modify HTML and Google Apps Script on your script editor as follows.
HTML & Javascript:Index.htmlGoogle Apps Script:Code.gsNote:
Reference:
If I misunderstood your question and this was not the result you want, I apologize.