Go to: Aardvark download page.

JavaScript

You have probably noticed that scripts sometimes are found in the head section of the page and sometimes in the body section. What's the difference?

Let's start with the less common "body script", they are used when the location of the code is vital.

  • If you want a script to display the text "hello world" between the existing text "I said" and "this morning." you need to place a body script in the middle of the sentence.

  • Another good example is if you want a script to add a random image at the bottom of your page. You will then need to place the script at the spot where you want the image to display.

  • A typical sign of the body script is that it contains the ", which gives the browser the instruction to write the text within the brackets to the page. The content can be HTML or plain text.


Head scripts is the most common type. When you don't need the special features of the body script you should use a head script. It's that simple!

Back to tutorial index <<