

| Okay, that rollover script wasn't so hard! But, hey! It makes Internet Explorer 3 in Windows throw up error messages! That's no good. Not if you care about people who still use Internet Explorer 3. Don't despair, we can write a script where you won't get any error messages. First, you will need those two images again that are exactly the same size. Here they are. One for 'on' and one for 'off'. |

See, it works here too. But what is the difference? Let me show you.
|
| Now, let's break it down so you can understand what you are doing:
This is an "if statement". What you are telling the browser here is "if you support the image object (document.images) then execute the following code." And if it doesn't support the image object, it will just ignore the code. This is how you prevent a browser that doesn't support the image object from giving you an error message. Be sure to close the 'if' statement with the closing bracket '}'.
This is a function. Here you are creating a function called button. You can pretty much call it anything you want. Inside the parentheses is a name for the variable that you will be passing from your onMouseover. It will be the name of your source image and also the first part of your image object's name. Notice first that I have given the image a name NAME="mybutton". Now look at the onMouseover. onMouseover="button('mybutton')" - See how I am calling the function "button()" and inside the parentheses I am putting the image name as a variable "button('mybutton')". Now the function will take that variable and read it like this:
The beauty of using a setup like this is that you can use the same function for all of your mouseovers just by changing the variable.
First you create a separate image object for each button: And then give each button image its own name and its own variable for the function:
Notice that each image has a different name. And I'm passing a different variable in the function for that link. "onMouseover="button('link'); That's it. Just pay attention to details. If it doesn't work, you probably have missed something. If you run into problems with this script, you can email me at pandason@best.com.
|