-->
Previous Table of Contents Next


The language option inside the <SCRIPT> tag is optional, but it is a good idea to use it to make sure the browser knows what script language it should use. If you want to load the JavaScript from a URL, you need to embed the URL in the <SCRIPT> tag like this:


<SCRIPT language=”JavaScript” src=”http://www.where.com”>

If the JavaScript source is embedded in the HTML file, you can leave off the SRC component. For example, here’s a very simple JavaScript applet in some HTML code (which has been trimmed down to the essentials):


<HTML>

<HEAD>

…

<SCRIPT language=”JavaScript”>

  alert(“Welcome to my Web site!”);

</SCRIPT>

</HEAD>

</HTML>

The alert() function in JavaScript displays the message in a window with an exclamation mark icon next to it. This is usually used to catch your attention when you try to do something critical, illegal, or that may cause potential problems. JavaScript’s functions, as you can see, are much like C. You can define complete function within a JavaScript file, similar to in a C program.

If you are calling a file with the JavaScript source in it from your HTML code, the convention is to name the file with the .js filetype at the end (sample.js, for example). This is because several applications, including MIME, already recognize the .js filetype and can handle them properly.

We don’t have the space here to go into details about JavaScript programming, but there are many good books on the subject.

Summary

We’ve taken a quick look at Java and JavaScript, both of which are available for Linux platforms in both server and client versions. Programming both Java and JavaScript requires a bit of past programming experience, but if you’ve programmed before you can use them both to add a lot of features to Web pages and HTML documents. Give them a try! After all, the software is free. Here are some useful chapters for you to read:

To learn about the Perl programming language, which is perfect for writing CGI scripts, see Chapter 28, “Perl.”
To learn about using C to write CGI scripts, see Chapter 26, “Programming in C.”
To learn more about HTML, see Chapter 53, “HTML Programming Basics.”
To learn about backing up your system so you don’t lose all the CGI scripts you’ve created, read Chapter 45, “Backups.”


Previous Table of Contents Next