Difficulty with onload script and CSS

I’m not going to post any HTML CSS or JS files (I will post snippets though) because I’m not looking for someone to do my work for me. I do

have a question though.
When my script runs via the <script src="main.js"></script> tag my page loads correctly, but when I use onload (which is required for the

assignment) like this: <body onload="main()">stuff here</body> and I wrap all my code into a function main() {} in my JS file, none of the

external CSS or HTML within the <body> tag loads.
I think it has something to do with when the script is loading but I’m not sure. Any help is appreciated!
Thanks!

Check the console log (F12) to see if there are any errors being reported.

HTH,

^ _ ^

instead of that place this…

<script>
(function() {
   'use strict';
function main() {
   console.log( 'hello' );
 }
   main();
}());
</script>

before the closing </body> tag.

coothead

Thankyou for the suggestion

Removed fake signature

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.