Webpage loses focus when innerHTML replaces DIVs containing INPUT fields

Symptoms
You have an HTML webpage that contains INPUT fields that are embedded in DIV tags. You use scripting in your webpage and replace the surrounding DIV container by using the innerHTML property. (This property also includes your focused INPUT field.) In this situation, the webpage no longer has the focus.
Cause
This problem occurs because the document.ActiveElement property is set to null.

Note It is the expected behavior in IE9 Standards mode and later modes that the document.ActiveElement property is set to null when you use the innerHTML property to replace the surrounding DIV container.
Resolution

Update information

To resolve this issue, install the most recent cumulative security update for Internet Explorer. To do this, go to Microsoft Update.

For technical information about the most recent cumulative security update for Internet Explorer, go to the following Microsoft website:Note This update was first included in security update 2888505.

For more information, click the following article number to view the article in the Microsoft Knowledge Base:
2888505 MS13-088: Cumulative Security Update for Internet Explorer: November 12, 2013

Workaround
To work around this problem when the content is changed by using the innerHTML property and when the document.ActiveElement is null, set the innerHTML property to the body by calling document.body.setActive(), as appropriate for your situation.
Status
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
More information
This update changes the functionality for the legacy IE7 document mode and IE8 document mode (such as in Compatibility View) in Internet Explorer 10 so that the document modes perform the same fallback as they did in earlier Internet Explorer versions:
  • When you use "Internet Explorer 7" document mode, the document.ActiveElement property is set to the BODY tag.
  • When you use the "Internet Explorer 8" document mode, the document.ActiveElement property is set to the HTML tag.
References
See the terminology Microsoft uses to describe software updates.
Properties

Article ID: 2905727 - Last Review: 11/15/2013 17:16:00 - Revision: 4.0

Internet Explorer 10

  • kbqfe kbbug kbfix kbexpertiseinter kbsurveynew KB2905727
Feedback