Link to home
Start Free TrialLog in
Avatar of tech1984
tech1984

asked on

Can't get a div onMouseover to change the innerHTML and keep it there

I have a simple but frustrating question regarding why I can't change the innerHTML of a div onMouseover and keep the contents there. The code attached will allow me to mouse over the div and will change the innerHTML to the image, but If I touch that image with the mouse, it executes as a onMouseout, because I assume it is not touching the div anymore. Any thoughts?

<script language="JavaScript" type="text/javascript">
function proof_image(action)
{
	if(action == 'on')
	{
	document.getElementById("image_holder").innerHTML = '<img src="../../images/proof_label.png">';
	}
	else
	{
	document.getElementById("image_holder").innerHTML = "&nbsp;";
	}
 
}
</script>
 
<div id="image_holder" onMouseOver="proof_image('on');" onMouseOut="proof_image('off');" style="background-image:url(thumbnails/thumb1.jpg); height:500px; width:500px; vertical-align:middle;">&nbsp;</div>

Open in new window

Avatar of HonorGod
HonorGod
Flag of United States of America image

Have you considered updating the onmouseover and onmouseout event handlers on the div during the onmouseover function?
Avatar of tech1984
tech1984

ASKER

No, how do you do that?
What browser(s)?
Well I need it to work in IE and Firefox.. I don't care about any others
The challenge is:

How exactly, we we want it to work?

Let's use the following diagram to represent the section of the browser associated by the DIV.

How are we supposed to differentiate a mouse movement from DIV "area" to the "image" area from one over the DIV area to away from the DIV area?

+------------------------------+
|                              |
|  +------------------------+  |
|  |                        |  |
|  |  Your Image Goes Here  |  |
|  |                        |  |
|  +------------------------+  |
|                              |
+------------------------------+

Open in new window

That is my question.. I thought making it a background image would work best, but I am using the background image for the actual image that I want display the mouseover image over..... if that makes sense.

This is going to take some thinking, and playing...
ASKER CERTIFIED SOLUTION
Avatar of Kelevra
Kelevra

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial