Scroll To Top

Enter a query to search our site. Note that you can use "*" and "?" as wildcards. Enclosing more than one word in double quotes ("CSS Layout") will search for the exact phrase.

PVII Knowledge Base

1. Select a product ...
2. Select category ...
3. Search the Knowledge Base...

Question #126

Is there an easy way to control the down-state image in a simple navbar I created with swap image behaviors?

The Answer

Prepared Mar. 2004 by Gerry Jacobsen, PVII

Here's a little script that will allow you to easily set the "down" state image on each page when using a swap image navbar:

1. Copy & Paste this into your page, in Source View, just before the ending </head> tag, but after any other <script> tags:

<script type="text/javascript">
  //set the down image name for this page
  var g7="myImageName";
  function P7_downImage(){ //v1.0 byPVII
  //set the down image name convention
  var g,dd="_down";

2. Add this to your <body> onLoad event,


the <body> tag will look like this:

<body onLoad="P7_downImage();MM_preloadImages('..

3. Now, to activate this, you simply need to specify the name of the image that you wish to be in the down state. For example, if you want the image named "Image1" on your page to be in the down state, then locate this in the script you just added to the page:

var g7="myImageName";

change the "myImageName" to reflect the name of the image you wish in the down state, like:

var g7="Image1";

4. The script uses a naming convention to append the existing normal image file name. For example, if your normal image file is "button.gif", then the script will append this with "_down", so it will assign the button to the image file "button1_down.gif". You can set the naming convention to anything you like, for example, if you are using "_f3" as the naming convention for your down image, then you can set this directly into the script:

Locate the third line in the "P7_downImage()" function:

var g,dd="_down";

to change it to use "_f3" as the down state naming convention, change this line so it looks like this:

var g,dd="_f3";

5. Save the page. Preview to test. The image name that you set will always be in the down state.

That's it!

Back to the questions list