A Javascript will work anywhere in the <head> or <body> of a document. While it is preferential to put the JScript in the head of a document (and in a separate .JS where possible), sometimes it is necessary or easier to put the JScript into the body of the document (e.g. if you're dynamically generating an array of pics to be used in conjunction with a randomly rotated image section).
It may not provide output code that HTML coders would like, but for the actual programmers it may be easier to understand.
As swstyles pointed out, some JScripts (such as a DHTML menu) will only work within the body of a document.
|