PDA

View Full Version : html link on a swapped image?


pininfarina
04-01-2007, 01:56 PM
I'm working on a site that is very basic in it's navigation.
I have set up behaviors for swapping a transparent image for an image with some simple text content on it that is not selectable (because it's an image).
I was wondering how I can put a link on the swapped image because only the transparent image is shown in dreamweaver?

is it possible to preload the swapped image in place of the transparent one so I can work with it in dreamweaver?

danlefeb
04-02-2007, 08:30 AM
A simple, yet effective way of preloading images is to simply hide it with CSS. So you'd put a class like this in your CSS document

.hideMyPic {display:none;}


Then, call that class from your image. It'll load, but won't be displayed until you change the class....which can be done with something like this:

<img src="URLTOIMAGE" class="hideMyPic" onmouseover="this.className='unhideMyPic'" onmouseout="this.className='hideMyPic'" />

tanya
04-02-2007, 09:13 AM
You can also use the following JavaScript function to preload images:

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

Call it from the body tag this way:

<body onLoad="MM_preloadImages('image1.jpg','image2.jpg');">

Hope this helps!

pininfarina
04-02-2007, 11:21 AM
that's what I was looking for, thank you that javascript function has just been saved for future reference