Microsoft KB Archive/817979

= OnChange Event Fires Unexpectedly When You Tab Out of a Text Area for the First Time =

Article ID: 817979

Article Last Modified on 11/15/2007

-

APPLIES TO


 * Microsoft Internet Explorer (Programming) 6 (SP1)
 * Microsoft Internet Explorer 5.01

-



SYMPTOMS
When you press the TAB key in a TEXTAREA control on a Web page, the OnChange event fires even though the contents of the control have not changed. That is, Internet Explorer incorrectly detects that a change occurred in the TEXTAREA control, even though no change is made.



CAUSE
This problem occurs if you use script to set the text of the TEXTAREA control, and if either of the following conditions is true:
 * The text contains only a line feed(&quot; chr(10)&quot; or &quot;\n&quot;) character.
 * The text contains a line feed(&quot; chr(10)&quot; or &quot;\n&quot;) character and a carriage return(&quot;chr(13)&quot; or &quot;\r&quot;) character, in that specific order.

In this situation, Internet Explorer incorrectly processes the text of the TEXTAREA control. As a result, the OnChange event fires, even though the contents of the object have not changed.



Internet Explorer 6.0 Service Pack 1
A supported hotfix is now available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next service pack that contains this hotfix.

To resolve this problem, submit a request to Microsoft Online Customer Services to obtain the hotfix. To submit an online request to obtain the hotfix, visit the following Microsoft Web site:

http://go.microsoft.com/?linkid=6294451

Note If additional issues occur or any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. To create a separate service request, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

The Global version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.   Date         Time   Version         Size       File name -  03-Apr-2003  17:44  6.0.2800.1184   2,787,840  Mshtml.dll

Internet Explorer 5.01 Service Pack 3
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Internet Explorer 5.01 service pack 4 that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question. The global version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.   Date         Time   Version         Size       File name -  02-Apr-2003  23:53  5.0.3517.200    2,356,496  Mshtml.dll



WORKAROUND
To work around this problem, do one of the following, as appropriate to your situation:   Use the carriage return character before the line feed character in the TEXTAREA control. The following code demonstrates a workaround for the example that was shown earlier in this article:       var str=&quot;A&quot; + &quot;\r&quot;+&quot;\n&quot; + &quot;B&quot;; document.all(&quot;TEXTAREA1&quot;).value=str; function test { alert(&quot;OnChange fired&quot;); }    </HTML> </li> <li> Set a global flag. For example: var flag = true; function test { //Workaround if(flag == true) {       window.event.cancel = true; flag = false; }      else alert('OnChange fired'); } </li></ul>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in Microsoft Internet Explorer.

<div class="moreinformation_section">

Steps to Reproduce the Problem
<ol> <li> Paste the following code in notepad, and then save it as TEXTAREA.htm. <HTML>  </HEAD> <BODY > </TEXTAREA> <script language=&quot;JScript&quot;> var str=&quot;A&quot; + &quot;\n&quot; + &quot;B&quot;; document.all(&quot;TEXTAREA1&quot;).value=str; function test { alert(&quot;OnChange fired&quot;); }   </BODY> </HTML> </li> <li>Double-click TEXTAREA.htm to open it in Internet Explorer.</li> <li>Click inside the TEXTAREA control, and then press the TAB key. An &quot;OnChange fired&quot; message appears.</li></ol>

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, see the following Microsoft Web site:

https://partner.microsoft.com/global/30000104

For additional information about the support options available from Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Keywords: kbhotfixserver kbqfe kbqfe kbie600sp2fix kbie600presp2fix kbfix kbbug KB817979

-

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

© Microsoft Corporation. All rights reserved.