Difficulty with onload script and CSS


#1

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!


#2

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

HTH,

^ _ ^


#3

instead of that place this…

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

before the closing </body> tag.

coothead


#4

Thankyou for the suggestion

Removed fake signature