Instead of adding dozens of lines of code directly to a web page, I created a .js file and uploaded it to my server. How can I call that file so I can execute the code in .js? Thanks in advance
1. <body onload="javascript: YOUR JS CODE GOES HERE"> 2. include jquery (that is what most of sites using today), and importantly can add as many handlers for load event you want. Download jquery js firt a) <script src="jquery-VERSION.js"></script> b) $(function() { YOUR JS CODE GOES HERE }); I hope it helps.
Does it absolutely have to wait for the onload event? If it doesn't, then it's as simple as creating an external JavaScript file, and linking it at the bottom of your code.