Microsoft KB Archive/185374

= PRB: document_onmouseout Fires When Mouse is Over HTML Form =

Article ID: 185374

Article Last Modified on 5/11/2006

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2

-



This article was previously published under Q185374



SYMPTOMS
The document_onmouseout event fires when the mouse moves over HTML formatted text, such as the example below although the mouse is still within the confines of the document: This is text Expected Behavior: The document_onmouseout event should only fire when the mouse leaves the document.



CAUSE
The onmouseover and onmouseout events fire based on the element that the mouse is over. When we go from the body (plain text) to a bold (or anything else), then we "leave" being over the document and are now over the bold object. For this reason, the onmouseout event fires for the  tag.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
  Create a Web page with the following content:   

Sub document_onmouseout Dim FromControl Dim ToControl

FromControl = "From:" + window.event.fromElement.id + " " ToControl = " To:" + window.event.toElement.id

MsgBox(FromControl + ToControl) End Sub    REGULAR TEXT BOLD TEXT</B> </BODY> </HTML> </li> <li>Move over the BOLD text.</li> <li>A message box appears with the text "From:Body To:Bold" indicating that the onmouseout event was fired from the body.</li></ol>

NOTE: This Script was written as it is to best illustrate which elements are entered and exited. If you move the mouse out of the document entirely, a script error will result because there is no "toElement".

<div class="references_section">