In order to use JavaScript, you must have a reasonably working knowledge of HTML. So hop on over there now and learn it before proceeding, because from here on in I'll be using it as if you know it already.

The majority of your scripts will sit in your <head> tag. This is because you know that it has been looked at (all of your functions and variables have been declared), and that you won't get any undefined variable or function errors.

But you can't just put it in there. You've gotta contain it in these tags:<script type="text/javascript"> and </script>. So here's an example of a whole web page with JavaScript and all..

<html>
<head>
<script type="text/javascript">
  var name = "Guest";

  function GetName()
  {
    name = prompt("Please enter your name!","");
  }

  GetName();

  document.writeln("<title>Welcome, " + name + "!</title>");
</script>
</head>
<body>
<script language=JavaScript>
document.writeln("Welcome to my web page, ");
document.writeln(name + ", I hope you enjoy your visit!");
</script>
</body>
</html>

As you can see, the bulk of JavaScript's work is done inside of the header tag - even before making the title. The document.writeln thing is a function that...you guessed it, writes a line! So all the HTML actually sees of the JavaScript is the stuff that it wrote with that function. The rest isn't there, as far as HTML is concerned. You'll also notice that you can actually execute functions inside of the header. Finally, notice that you can actually put script anywhere. Just separate it with those tags and all is well!