PRB: document_onmouseout Fires When Mouse is Over HTML Form

ID: Q185374


The information in this article applies to:
  • Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 5.0


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, please see the MSDN Web Workshop:

http://msdn.microsoft.com/workshop/default.asp

Additional query words:

Keywords : kbIE400 kbIE401 kbDSupport
Version : WINDOWS:4.0,4.01,5.0
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: July 22, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.