This page covers the following topics:
Here's an example that illustrates all these points.
Suppose we have a file called test.js, as follows.
In the same directory on my computer, I've created a file called test.html, like this:
Now if I open test.html with my browser, I get this:
If I wanted this to run from a webserver (as you usually do), I'd upload the .js file and make sure it was accessible via a url such as http://www.caveofprogramming.com/scripts/test.js. I can then change my HTML like this:
Here's an example HTML page that pops up an alert when a button is clicked.
The following example embeds HTML both ways.