|
Well, its time to try out your first javascript. This one is nice because
we don't have to deal with the adding the script tag. This little script
will write something of your choice to the browser's status bar when you
move your mouse over a link. Let's look at the example:
<A HREF="jmouse.htm" onMouseover="window.status='Hi there!'; return true">Place your mouse here!</A> I'll explain all this in a second. Go ahead and see what it does. Place your mouse pointer over the link, but don't click it. Now look down at the status bar at the bottom of your browser. It will say "Hi there!" Okay, here's what is happening with the onMouseover command: onMouseover=" " This is the form of the onMouseover command. The browser expects another command or function inside the quote marks. window.status='Hi there!' This command instructs the browser to write to the status bar. You place what you want the browser to write inside the single quote marks. return true Returns the statement as true so the browser will display the text. The reason for the single quote marks is because in this case, the window.status command is used inside the onMouseover command, which was already using double quotes. If we had used another set of double quotes, the browser would have gotton confused about waht it should do because it would think the onMouseover command had ended when we began the window.status command: onMouseover=""window..... Well, one thing that could be bugging you is the fact that the "Hi There!" is now in your status bar and won't leave. There are two ways to fix this problem. One way is to use the onMouseout command, and another is to call a fuction that will erase the text after a specified amount of time. The second way requires using functions and the script tags, so for now I will show you the easiest way to do it: the onMouseout command. Here it is: <A HREF="jmouse.htm" onMouseover="window.status='Hi there!'; return
true" onMouseout="window.status=' ';
Well, now that you have this, let's see about using buttons and the
"onClick" command to make some things happen. Let's go on to Using
Buttons for JavaScripts.
|
This page was created by Bob
Perini
|