Java Certification, Programming, JavaBean and Object Oriented Reference Books
Lesson One - The basics of JavaScript

Like other programming languages, JavaScript has its' own rules and techniques. However, JavaScript needs HTML to function because it is a scripting language. Instead of creating programs, you will be creating enhanced Web pages. 

You begin with a tag that includes SCRIPT LANGUAGE="JavaScript". This tag tells the browser that you are going to be programming in JavaScript. This half of the program was put in the HEAD of the document. Between this tag and the corresponding /SCRIPT is where you place your statements. The first statements are the document.write() and document.writeln(). document.writeln() can only be used with the HTML PRE tags for the simple reason that it adds carriage return which only PRE tags recognize.

Some programs can be accessed from a source file. You would add a souce file by typing SRC="c:\jscript\sourcefile.js" within the opening SCRIPT tag at the end of the tag. This not only makes your document more neat in appearance, it makes it easier for other programs to access the same program, and it hides the actual code so that other people cannot see it. You can use either form, however, if you use a source file in the same SCRIPT block as an embedded program, the embedded program will be ignored.

Question: That seems too simple. If that's all there is to JavaScript, why not just learn HTML?

Answer: Because, like programming languages, JavaScript requires variables, functions, objects, and events. This is what we will be learning next.

Return to : Java Programming Hints and Tips