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!

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


^ _ ^

instead of that place this…

(function() {
   'use strict';
function main() {
   console.log( 'hello' );

before the closing </body> tag.


Thankyou for the suggestion

Removed fake signature

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