irst, a formal description:
It is a programming language that can make your pages feel more dynamic and give feedback to your user. This is a good argument for learning and incorporating it into your web techniques basket.
No. Nope. Not the same.
They two are different creatures that share only an object philosophy and a similiar name.
- Java is a compiled programming language, comparable to languages such C, C++, or Pascal.
Everything from small applets (tiny programs) to entire shrink-wrapped applications are being created in Java. Many in the programming world predict that Java will eventually replace C and C++ as a language of choice for application development.
A Little History…
More Than You Might Want to Know, But…
Within the Web environment, the most common use of Java is to build applets, small programs that launch automatically from within a Web page. When the Web page loads, these applets are launched and begin to run on your local computer. While the applet runs, your browser sits quietly by.
On the plus side, running a Java applet doesn’t consume server time. It makes it possible for small, self-contained programs to be delivered via the Web, but run locally on individual computers. However, downloading Java applets has some people concerned about security; in corporate environments, Information Systems departments sometimes set up procedures to screen out external Java applets and prevent them from being downloaded. These IS managers fear (rightly or wrongly) that the applet could infect the system or be, in some way, a threat to the network.
- Provide visual feedback to a reader action.
In this example, try putting your cursor on the menu choice and watch for the glowing dot that appears.
- Add a little explanatory text in the status bar (located at the bottom of the browser window) when the reader moves the mouse in certain places.
Notice what happens in the status bar when you move your mouse over each of the celestial bodies.
- Change the graphics on the screen as the reader moves the mouse around the browser.
In this example, your mouse movements make the comet fly as you move the cursor in the window.
- Display information based on the time of day.
In this example, you’ll see different date boxes every day. The script checks the computer’s clock and pulls the appropriate graphics based on the clock information.
Look at a Script
The script appears between them. Most often, the script will be at the very beginning of the HTML text file.
In most cases, it is good style to place the scripts first. In other cases, it is essential that the script is first. For example, if you are using a script to see what type of browser the reader is using and to deliver the appropriate page for that browser type, the detection script must be the first thing in the file or the script won’t work correctly.
This is an example of a script. Click on it to see how it acts. The example appears in the window at the top of the screen:
This is a very simple script:
- The first line tells the document to write a line of text. The text to write is the words “This line of text” followed by the HTML break tag.
- The second line tells the document to write a second line of text. The text is “Is generated by a script.”
That’s all the script does. It can be as simple as that.