BUG: Onmouseout Fires for SELECT When Cursor Still in Bounds (254614)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 4.0
  • Microsoft Internet Explorer (Programming) 4.01
  • Microsoft Internet Explorer (Programming) 4.01 SP1
  • Microsoft Internet Explorer (Programming) 4.01 SP2
  • Microsoft Internet Explorer (Programming) 5

This article was previously published under Q254614

SYMPTOMS

If you have an event handler set for the onmouseout event of an HTML SELECT element, this handler fires when you bring the cursor to rest inside the SELECT element.

RESOLUTION

Change your event handler to detect whether or not the onmouseout event being fired is accurate or not. You can do this by examining the value of window.event.toElement, which in this circumstance will be Nothing (in VBScript) or null (in JScript).

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Save the following HTML text to a file named testSelect.htm:
    <html>
    
    <head>
    
    <title>SELECT OnMouseOut Bug Reproduction</title>
    <script language="vbscript">
    sub SelectMouseOver()
    	window.status="Inside SELECT"
    end sub
    
    sub SelectMouseOut()
            window.status = "Outside SELECT"
    end sub
    </script>
    
    </head>
    
    <body>
    
    <form>
    <select size="1" name="foo" onmouseover="SelectMouseOver()" onmouseout="SelectMouseOut()" 
    
    language="vbscript">
      <option selected>Option 1</option>
      <option selected>Option 2</option>
      </select>
    </form>
    
    </body>
    
    </html>
    					
  2. Load this file into Internet Explorer and put the cursor inside the SELECT element. The "Inside SELECT" text will appear briefly in the status bar, followed by the "Outside SELECT" text.
  3. To avoid this, change your event handler to fire its code only when the toElement property of the event object is missing:
    sub SelectMouseOut()
    	if window.event.toElement is Nothing then
    		window.status="Not really outside SELECT!"
    	else
    		window.status = "Outside SELECT"
    	end if
    end sub
    					
    If using Microsoft Jscript, phrase this conditional as:
            if (window.event.toElement == null)
    					

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:kbBug kbDHTML kbpending KB254614