Microsoft KB Archive/818505

= Focus events incorrectly fire when you click the scroll bar in DIV in IFRAME =

Article ID: 818505

Article Last Modified on 11/1/2005

-

APPLIES TO


 * Microsoft Internet Explorer 6.0
 * Microsoft Internet Explorer 6.0 Service Pack 1

-





SYMPTOMS
When all the following conditions are true, and the user clicks the scroll bar in the DIV element while focus is on the text box, the onblur and onbeforedeactivate events for the text box fire, and the onfocus event for the DIV element fires, but the pointer still stays on the text box:
 * An HTML page contains an IFRAME element.
 * The IFRAME element contains a DIV element that has a scroll bar.
 * The HTML page also contains a text box.



CAUSE
There is a bug in the event handling mechanism in Microsoft Internet Explorer that causes these events to fire when they should not.



WORKAROUND
To work around this problem, use one of the following methods:
 * Do not rely on these events.
 * Do not make the scroll bar available if the focus is not in the IFRAME element. For an example of how to do this, see the &quot;More Information&quot; section.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the problem
  Create an HTML page that contains the following code:  Expected behavior When clicking scroll bars in IFRAME or DIV, the focus functions do not fire and the text box remains in focus. Actual behavior When you click scroll bars in the DIV element, the focus functions do fire, and the text box remains in focus. Use workaround   </li>  Create the HTML page for Iframe.htm by using the following code: <div id=&quot;mydiv&quot; style=&quot;height: 150px; background-color: gray;overflow-y: scroll&quot; onfocus=&quot;body.insertAdjacentHTML('afterbegin', 'div onfocus fired. ')&quot;> 1 2 3 4 5 6 7 8 9 10 </li> Open the page in Internet Explorer. Make sure that the Use workaround check box is cleared.</li> To see the problem, click the scroll bar in the DIV element that is inside the IFRAME element. Notice that the events fire, but the pointer is still in the text box.</li> Click to select the Use workaround check box, click one time inside the IFRAME element, and then click one time outside the IFRAME element to remove the DIV element scroll bar.</li></ol>

The workaround involves dynamically adding the scroll bar of the DIV element if the IFRAME element has focus. Because the DIV element scroll bar does not now exist, you cannot experience the problem. If you click the DIV element, or if you click inside the IFRAME element, the events will still fire, but the focus is no longer on the text box. Notice that the scroll bar for the DIV element also appears. The one drawback to this workaround is that the user cannot scroll the DIV element content while keeping focus on the text box.

Keywords: kbbug kbfix kbie600presp2fix kbqfe kbie600sp2fix kbhotfixserver KB818505

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.