That will invoke the functions, but it doesn’t assign anything useful to window.onload unless your last function happens to return a function.
You need to assign a function to window.onload that will invoke your functions when the window is ready.
window.onload = function() {
foo();
bar();
};
Plus, since you’re putting the script at the bottom, you probably don’t need the window.onload.
<script>
foo(); bar();
</script>
</body>
You should also be aware that assigning directly to window.onload will overwrite the script assigned in the <body onLoad=...>, so you shouldn’t do both. Currently, the return value of bar(); is wiping out the function that invokes display();.
Getting rid of the window.onload assignment will fix that.
17
solved Javascript function in html body, wont work