Help - Search - Members - Calendar
Full Version: image change in DIV
HTMLHelp Forums > Programming > Client-side Scripting
edwardx
Hi All,

I am trying to put my first page together and I want to have a series of DIV to make a nav bar, ie home, info, contact.

I found this on a page

<div><a onmousedown="changeImages('b42_artists', '../../-WEB%20FILES/images/b42_artists-over.gif'); return true;" onmouseup="changeImages('b42_artists', 'images/b42_artists-over.gif'); return true;" onmouseover="changeImages('b42_artists', 'images/b42_artists-over.gif'); return true;" onmouseout="changeImages('b42_artists', 'images/b42_artists.gif'); return true;" href="artists.html"><img class="dsR79" src="b42_artists.gif" alt="" name="b42_artists" height="53" width="118" border="0" /></a></div>

But don't understand how to mod it to use my images??

Your help is much appreciated!!
Darin McGrew
Since this thread is about JavaScript, I've moved it to the appropriate forum.
Christian J
The image paths are contained in the function call, e.g. "images/b42_artists-over.gif" so it seems you just have to change that. But the various mouse events call the function changeImages(), which is absent from your code example. You should also preload the mouseover images, to prevent delays while the images load.

Here's another way to make rollovers with CSS only: http://www.wellstyled.com/css-nopreload-rollovers.html
Website Design Perth
Def. recommend achieving this with css (in an external file, of course) marked up something like this (snippet from our site):

CODE
<div id="nav">
     <ul>
       <li><a href="website-design-perth-web-ecommerce-Generator.html">Website Design</a></li>
       <li><a href="web-marketing-search-engine-optimization.html">Web Marketing</a></li>
       <li><a href="marketing-agency-perth-brand-building-strategy.html">Brand-Building</a></li>
     </ul>
</div>

Frederiek
You effectively don't have to use a DIV for each link, that would created a tag soup of redundant DIV's. A list, as Website Design Perth indicated, is a good way to code it and then use CSS to swap the images. See Listamatic and the URL Christian pointed you to.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.