View Full Version : InnerHTML mouseover question

Philip M
Dec 8th, 2003, 08:54 AM
I find that:-

<p onmouseover="this.innerHTML='<B>Mouse out to change back.</B>'" onmouseout="this.innerHTML='<I>Mouse over again to change.</I>'"><I>Mouse over this text to change it.</I>

does not work correctly in that the onmouseover part
works fine, but the change back on mouseout does not fire if the
user's mouse pointer is moved away directly vertically up or down
from the changed text. To make the change the pointer must be moved to the right away from the text, then up or down.

I am using IE5.5.

Any comments or solutions, please?

(Oh horror! I see that I have become a JavaScript addict!!!
Is there no category for JavaScript smallbrain or slow-wit?)

Dec 8th, 2003, 09:38 AM
A statement: The event handlers do fire all the directions but only if the mouse moves over/out the DIV itself, not the text... I presume that the new tags (bold and italics) are responsible to this... If remove them, the handlers will do the job properly... Hm.. I think that you may insert the handlers in the B tags and the I tags also... but seems like an intricate solution....

Philip M
Dec 8th, 2003, 07:31 PM
Thank you Kor!

The following appears to work OK so it looks as though
the <i> tags are the problem.

<p onmouseover="this.innerHTML='Mouse out to change back.'" onmouseout="this.innerHTML='Mouse over AGAIN to change.'">Mouse over this text to change it.

Dec 8th, 2003, 07:39 PM
...read this while in rehab: :thumbsup:


Dec 9th, 2003, 09:52 AM
I think you will have no problem if using CSS style to give italic and bold properties to text instead of using HTML tags.