PRB: document_onmouseout Fires When Mouse is Over HTML Form (185374)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 4.0
  • Microsoft Internet Explorer (Programming) 4.01

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:
   <B>This is text</B>
				
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 <BODY> tag.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a Web page with the following content:
       <HTML>
       <HEAD>
          <SCRIPT LANGUAGE=VBSCRIPT>
    
          Sub document_onmouseout
             Dim FromControl
             Dim ToControl
    
             FromControl = "From:" + window.event.fromElement.id + " "
             ToControl = " To:" + window.event.toElement.id
    
             MsgBox(FromControl + ToControl)
          End Sub
       </SCRIPT>
       </HEAD>
       <BODY id=theBody>
       REGULAR TEXT<BR>
       <B ID=Bold>BOLD TEXT</B>
       </BODY>
       </HTML>
    						
  2. Move over the BOLD text.
  3. A message box appears with the text "From:Body To:Bold" indicating that the onmouseout event was fired from the body.
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".

REFERENCES

For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

Modification Type:MajorLast Reviewed:5/11/2006
Keywords:kbprb KB185374