billven billven - 1 month ago 5x
HTML Question

Call javascript from HTML

I have a HTML file with the content:

<script src="">
function test()
//Function stuff

However, I'd like to write all my javascript (Function test) in a separate document (.js). How do I refer to, or call, this separate file so I get the same result as if the code was directly in the HTML?

I need the to ease the graphics handling in function test.


In the html section, refer to the file that contains your javascript, I'm assuming the html file is in the same folder as that containing your script.

<script src="script.js"></script>

If the script is in a different folder...

<script src="/path/to/script.js"></script>