image replace on mouse over

K

krig

hi
i am trying to replace an image source on mouse over. sometimes it
takes a few seconds for the image to be replaced when the cursor is on
it and sometimes it happens fast. what do i need to do? here is the
code:

<img name="designcolornavyblue" height="23" width="106" alt=""
border="0"
onmouseover="design_color =
'navyblue';document.designcolornavyblue.src ='http://
i8.ebayimg.com/06/i/000/ba/87/be23_1_b.JPG';
setShirtImg();setDesignColorText()"
onmouseout="document.designcolornavyblue.src='http://
i4.ebayimg.com/07/i/000/ba/87/be6c_1_b.JPG';"
src="http://i4.ebayimg.com/07/i/000/ba/87/be6c_1_b.JPG">
 
D

David Mark

hi
i am trying to replace an image source on mouse over. sometimes it
takes a few seconds for the image to be replaced when the cursor is on
it and sometimes it happens fast. what do i need to do? here is the
code:

You need to preload the images.
<img name="designcolornavyblue" height="23" width="106" alt=""
border="0"
onmouseover="design_color =
'navyblue';document.designcolornavyblue.src ='http://
i8.ebayimg.com/06/i/000/ba/87/be23_1_b.JPG';
setShirtImg();setDesignColorText()"
onmouseout="document.designcolornavyblue.src='http://
i4.ebayimg.com/07/i/000/ba/87/be6c_1_b.JPG';"
src="http://i4.ebayimg.com/07/i/000/ba/87/be6c_1_b.JPG">

And why are you using entities in your event attributes?
 
T

Thomas 'PointedEars' Lahn

krig said:
i am trying to replace an image source on mouse over. sometimes it
takes a few seconds for the image to be replaced when the cursor is on
it and sometimes it happens fast. what do i need to do?

You can try preloading the image resource to the UA's cache so that it is
then retrieved from there instead, but there is no guarantee that this will
have the desired effect. Cubic scaling down of the image *before* upload is
probably the better approach in your case.
here is the code:

[...]

Yuck! Anything is better than this code. For example:

http://PointedEars.de/scripts/test/dom/hoverMe/


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top