Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: OnChange Event of <SELECT> Fires Incorrectly in a FRAME When Refreshed Programmatically

View products that this article applies to.


If you have a FRAMESET object with a FRAME that contains a SELECT control and an INPUT TYPE=TEXT or TEXTAREA control, and the OnChange event of the TEXTAREA control reloads the page, the OnChange event of the SELECT may fire after the page reloads. This behavior may occur even if you do not select a new item from the SELECT control.

↑ Back to the top


This is a regression from Internet Explorer 5.5.

↑ Back to the top


To work around this problem, you can use one of the following methods. The method you use depends on the usage of the elements in your application.
  • Disable the Select box before the page unloads.
  • If you must submit a form, check the document.readyState property in the OnChange event before you submit the form. You must check this value in the OnChange event before you submit the form because this bug may cause two submits to occur at the same time, one submit from the Select box and one submit from the text box.

↑ Back to the top


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

↑ Back to the top

More information

The problem that is described in the "Symptoms" section of this article may also apply to other events of the SELECT element, such as the onbeforeactivate event. The problem occurs if an unload is triggered from an event of an object that fires when the event loses focus (OnChange event, onblur event).

Steps to Reproduce the Behavior

  1. Use the following code to create a FRAMESET:
    <TITLE>Test for Q319741</TITLE>
          <FRAME SRC="testFrame.html" NAME=MAIN>
  2. Save the file as Frameset.html.
  3. Create a new Hypertext Markup Language (HTML) file with the following code.
    function selectOnchange()
       // workaround 2
       // if (document.readyState == 'complete')
       alert('select is changed');
    function inputOnchange()
       // workaround 1
       // select1.disabled=true;
    <SELECT id=select1 onchange="selectOnchange();"> <!-- using onBeforeDeactivate will cause the problem too -->
       <OPTION value=-1>Select</OPTION>
       <OPTION value="option1">option1</OPTION>
       <OPTION value="option2">option2</OPTION>
       <OPTION value="option3">option3</OPTION>
    Please type text inside this textbox: <input type=text onchange="inputOnchange();"></input> <!-- using onBlur will cause the problem too -->
  4. Save the file as TestFrame.html.
  5. Place both .html files in the same directory.
  6. Locate the Frameset.html file.
  7. Click in the text box and type some text.
  8. Click the arrow on the SELECT box. This causes the OnChange event in the text box to fire.
After you click the SELECT control, a Window.alert MessageBox appears even though the currently-selected OPTION in the SELECT control does not change.

↑ Back to the top


For more information, visit the following MSDN Web sites:

↑ Back to the top

Keywords: KB319741, kbpending, kbbug

↑ Back to the top

Article Info
Article ID : 319741
Revision : 9
Created on : 11/29/2007
Published on : 11/29/2007
Exists online : False
Views : 393