Articles in this section:
Our recommended reference books:
Java and Javascript
Javascript
Javascript is a scripting language that is interpreted and executed by the client (browser). To include this kind of scripts, the web pages include the instructions that the client computer will execute thanks to the browser application. Usually the script resides within the web page file, among the rest of usual HTML tags, although it can also be called from an exernal, linked file with the extension .js. One advantage of this approach is the simplicity of changes or updates in the script. If you modify this external file, every page that includes a link to it will get a fresh version of the script with no need to change any of the web pages.
What is Javascript good for? It has many uses: no matter how little we have navigated the net, we will have seen dozens of applications; many of the functions that now we find in today’s web pages are based on Javascript, because all current navigators (version 3 or later) support it without problems. The functions of those scripts are very diverse: in general, they make navigation richer and more interactive. For example, the effects of “mouseover” or change of images when moving the mouse over, are prepared with JavaScript. But there are many other effects and additions for web pages that are based on it: pull-down menus, colour selection tools and many more. Other examples of applications in Javascript:
- Bookmarklets and favelets. Small scripts that are extremely useful for web developers. They execute mini applications (applets) that add features built from DHTML to your browser. Most are self-contained, but some link to other scripts or files on the web. The most simple weay to execute them is saving them as bookmarks; when you “visit” this “address” the script runs performing its action. You can get a good selection of these scripts at Squarefree.
- Alarms - to generate messages that appear when the visitor does something, for example, before entering a page. For example, they can remind of an appointment or show a different quote or motto every day.
- Calendars, clocks...
- Text boxes, independent of the rest of the page (used, for example, to include legal information, terms of use, licences...)
- Forms for electronic mail, for example to do a survey. There are many types of peculiar forms; some even serve to create a web page code from the navigator.
- Effects of audio and image, such as a change of colour of the background or a colour picker.
- Simple games to play online.
- Effects with the images: mouseovers, slideshows.
- Getting, editing and displaying any kind of information related to the currently loaded document. Very useful for web developers; some of these scripts can fit the favelet category (see above.)
- And many more! The list would be interminable!
How to include Javascript in a web page.
Another question is how to include the necessary Javascript code in the page. We would have to know the programming language to include it in the HTML directly; luckily, thousands of ready-to-use scripts already exist, written by programmers that have made them available worldwide; it is enough to copy the code (that comes surrounded, as the rest of HTML labels, within the tags <script> and </script> and paste it in the suitable position. For some very used script functions, such as rollovers, some programs of web edition already include a visual or wizard based system to introduce the script still more easily, so you don’t even have to stop working in visual mode to include it in the page.
Sometimes it is necessary to introduce some modification, like changing the text, or adapting it to our necessities. The possibilities of Javascript are immense, and you should give it a try. The browsers that practically everybody uses support this language perfectly —unless the option has been deactivated, which is not habitual— and we can obtain many ready made examples to use in webs like Javascript Source or Hotscripts.com. FirstPage 2000 and other programs also include a huge scripts library, ready to insert in your web pages.
DHTML
This abbreviation stands for Dynamic HTML. One type of pages that include a combination of Javascript code and definition of style and page structure with CSS, to generate visual effects and actions in the web page. For example, draggable content boxes that can be moved arbitrarily on the page. If your navigator is Explorer 4 or later, Mozilla or Opera, you can enjoy this type of pages.
The most important applications of DHTML, aside from more or less showy effects with the text, are the generation of pull-down menus and slideshow, and other possibilities. Again, to program all this is not for novices, but we have an abundance of ready to use scripts; some programs like Golive, Dreamweaver or Netobjects Fusion even allow you to generate code of DHTML visually. Read more about DHMTL in the next article.
Java.
Rather than a simple scripting language, Jave is a powerful programming platform —you can write a complete program in it, like the StarOffice suite— and it also can be used as web application to make pages more interactive and add new features to them. Unlike Javascript, the programs written in Java are always linked from the page. Usually they are called an applet (“mini-application”), and they are files with the extension class. When the page that contains the applet is visited, this is downloaded to the computer of the visitor and is executed (the navigator warns with a message of “initialized subprogram” or “executing Java”.) There are also Java applications that are executed in the server (servlets.)
Java is an island in Indonesia in which excellent coffee is grown. It seems the developers of the language were fans of this particular coffee , because it seems the name of Java is in honor of this variety of coffee (the Java logotype is a smoking cup; the Web sites dedicated to the subject make their own interpretations of this motif.) Java can be executed in the current navigators with no problems, but it is also possible that the option is deactivated (in the preferences of the navigator) or the user doesn’t have the Java plug-in installed in his machine. In these last cases, when a page that contains an applet, instead of it appears an empty gray box, with a message saying that the navigator does not support Java (something like “sorry, your to browser doesn't support Java”.)
The supply of applet of Java also ample and varied. Aside from the independent applications written in Java, there are many available applets, many of them free. In prior versions of this site we had several of these applications, for example a Java sitemap (denifitely not a map of Java!) Other examples include simple utilities like the calculator you can see on the left. It should work fine, just try it!
There are sites specialised in Java: Sun (offering the free Java plugin and a navigator called HotJava), Java Boutique, an excellent resource with tutorials, complete applet archive and more; other resources are Freewarejava and Javapowered.
The applet offer is extensive, and some applet do something that could be done by other means, for example, with Javascript or Flash; for example, in Java Boutique the applets are classified in several categories: Text effects; Navigation, Menus, Image maps, banners, buttons, Network: chat, email..., Educative: computers, simulators... effects of Audio, Games, some very spectacular and amusing, Utilities for websites, as databases, sitemaps and visual Effects: animators, changes of colour, slideshows. It also includes a section dedicated to Java Applications that are executed like a normal program, not in the browser.
To insert a Java applet in a web page isn’t very difficult either; in a visual publishing program is simply a matter of choosing an option in the menu (like Insert|Java Applet) and a dialog similar to the one shown here appears, where you simply have to indicate the name of the applet and specify a few parameters, following the instructions of the programmer. These instructions are usually included, along with some example, with the applet that you download from the internet.
