The next command that we will discuss is the Javascript command. Javascript is very similar to Java but it is a little easier to work with because the entire program is contained in the source code of the document. When using java I sometimes get a class not found error and I have to go back and find were I mess up in my applet command. This error is not possible with Javascript. However, java is a great deal more advanced in the types of programs that are being written for it . Most Javascript programs are for doing simple things that normally do not require much programming. People have tried to do advanced programing with javascript but it is still more desirable to write advanced programs in java.
No matter what type of Javascript program you use on your page you still need to follow a basic set of commands for incorporating them into your page. The first thing that you must know is that almost all Javascript programs appear in the HEAD area so if you have a javascript program that is not working see if it is in the HEAD area. The second thing that you must know is that javascript programs sometimes have modifiers in the BODY command so this should be your second possible reason for a program that is not working. After you have taken care of that it is now time to write the program. For an example, I am using a program that displays certain text in place of the location when you hold your mouse over it. To start I will first tell the browser that I am going to use Javascript in my document. To do this I will enter an angle bracket “<“ followed by the words SCRIPT LANGUAGE followed by an equal sign “=” followed by the word Javascript followed by an angle bracket “>”. Because browsers that do not support Javascript cannot handle it, you should comment the entire script out so that only browsers that understand the script will use it. To do this you will enter the begin comment command at the beginning of the script and the end comment command at the end of the script. Then you will enter the Javascript. This book does not tell you how to write in Javascript so you will either enter a Javascript that the author of it said you could use or write one yourself. After you have entered the script you will end it with a command that is an angle bracket “<“ followed by a slash “/” followed by the word SCRIPT followed by an angle bracket “>”. The following script makes the location box say whatever you want it to. To do this the script puts a modifier in the A HREF command “onMouseOver” and in this command does not appear in the HEAD but in the body of the document. The Javascript with commands looks like this:
<script language="JavaScript">
<!-- Hide
function moveover(txt) {
window.status = txt;
setTimeout("erase()",1000000);
}
function erase() {
window.status="";
}
// -->
</script>
<A HREF="http://computing.net" onMouseOver="moveover('Why not visit Justin Weber’s Computing Center and get some help!');return true;">