Hi
i have the used the below code to switch the button image on mouseover
and mouseout.
Code:
<html:button property="Button" value="Display" styleClass="displaybutton"
onmouseover="this.className='displaybutton displaybuttonover'"
onmouseout="this.className= 'displaybutton'"/>
CSS definition of displaybutton and displaybuttonover is shown below.
Code:
.displaybutton {
background: transparent url("/images/btnDisplay.gif") no-repeat;
width:64px;
padding: 22px 0 0 0;
overflow: hidden;
height:17px;
border:0;
cursor: pointer; /* hand-shaped cursor */
cursor: hand; /* for IE 5.x */
}
.displaybuttonover {
background: transparent url("/images/btnDisplay_over.gif") no-repeat;
}
but it produced delay in switching the image on mouseover in IE browser alone.
To avoid this delay i thought of using the below code on load to preload the image.
Code:
function imagePreloader()
{
objImage = new Image();
var buttons=new Array('btnDisplay_over.gif');
for(i=0;i<buttons.length;i++)
{
objImage.src='/images/'+buttons[i];
}
}
but i belive this is not good solution, Is there any other effective way to Preload images, because similar to display button, i have large number of buttons in my site, so preloading all of them with imagePreloader() function might increase the delay in loading the page. Can any one suggest me a better solution?
Thanks in Advance !!!!
Kindly Notify me if my question is unclear .