|
OnMouseOver
The code below is used at the top of the page. Put the code in the HEAD section of the html inbetween the <head> and </head>. By viewing page source of this page you will see exactly were we put the code on this page. In this JavaScript function pay close attention (for a moment) to the "if (document.images)" part. This little bit of JavaScript trickery protects your browser from trying to run code it is not able to. If you browser does not support the (document.images) array then this variable will not exist and this "if" statement will come back false and the code will not be attempted. This keeps your browser from trying to issue code that it doesn't understand. Nice. In this example we have used the graphics btn1_on.gif btn1_off.gif etc. You can of couse use any gif or jpg files of your choice.
<script language="JavaScript"> Here is a listing of the code used for the graphic image above:
Please take note of a few things. Each image used in the onmouseover button routine has the name="" attribute used. Also if you study the changeImages function you will note that any number of name/image pairs can be sent in one function call. The button to the left is the same as the upper button with just the names changed to add another button. Try clicking back and forth for awhile. We have picked up this code from an article on the http://www.builder.com website. They have some great material there. Once you get to builder.com lookup "onmouseover" through the onsite search. You can also try to access http://builder.com/Programming/Kahn/092398/ss01.html directly.
|