Microsoft KB Archive/294984

= BUG: Internet Explorer 5.5 Fails When You Access an Element Whose Display Style Is Set to None =

Article ID: 294984

Article Last Modified on 5/11/2006

-

APPLIES TO


 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer (Programming) 5.01 SP1
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q294984



SYMPTOMS
If you try to modify an element that has its focus and display style set to NONE, you receive the following access violation in the browser:

The instruction at &quot;0x011168db&quot; referenced memory at &quot;0x00000004&quot;. The memory could not be &quot;read&quot;.



CAUSE
An HTML element cannot have focus while its display style is set to none.



RESOLUTION
There are two ways to work around this problem:
 * Shift the focus away from the element before you set its display style to NONE.
 * Use the window.setTimeout method to delay execution of the code that modifies the hidden element.

NOTE: The amount of time that you must be set depends on computer's capability. If the delay time is not long enough, Internet Explorer may still fail.



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



MORE INFORMATION
The following code reproduces the behavior: 

function test {       thediv.style.display = &quot;none&quot;; thediv.innerHTML = &quot;a&quot;; }

/*    *   Use test1 or test2 to show the workarounds. *  Just change the function call in the onclick *  event of &quot;thediv&quot; to either test1 or test2. */

function test1 {       // Give focus to another element to resolve the problem. inp.focus; thediv.style.display = &quot;none&quot;; thediv.innerHTML = &quot;a&quot;; }

function test2 {       thediv.style.display = &quot;none&quot;; window.setTimeout(&quot;newFunction&quot;, 1000); }

function newFunction {       thediv.innerHTML = &quot;a&quot;; }

 Click on this div and it will disappear 

