Microsoft KB Archive/208534

= FIX: Index Parameter for the Add Method Behaves Differently for Options and Areas Collections =

Article ID: 208534

Article Last Modified on 5/11/2006

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2

-



This article was previously published under Q208534



SYMPTOMS
The options and areas collections are both 0-based collections; however, in Internet Explorer 4.x, the Add methods of these collections behave differently. This may cause compatibility issues.



CAUSE
In Internet Explorer 4.x, the Add method uses a 1-based index for the areas collection but a 0-based index for the options collection.



RESOLUTION
To resolve this problem, upgrade to Internet Explorer 5, in which both collections use a 0-based index.



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

This bug was corrected in Internet Explorer 5.



MORE INFORMATION
The following code adds the new option to the second position of the options collection. However, it adds the new area to the first position of the areas collection.   Area Collection Bug  //Add to Area collection. function Add2Area {   var y = document.createElement("area"); y.coords = "8,80,8,80"; catfish.areas.add(y, 1); Populate; }

//Add to Option collection. function Add2Options {     var y = document.createElement("option"); y.text = "newone"; selects.options.add(y, 1); Populate; }

function Populate {   var s  = ""; var x = catfish.areas for (var k=0;k"; Areas.innerHTML = s;   s  = ""; x = selects.options; for (var k=0;k"; Options.innerHTML = s }  

 <BUTTON onclick=Add2Area>Add to area (index 1)</BUTTON><BR> <IMG height=100 src="catfish.jpg" width=100 useMap=#catfish> <MAP name="catfish"> <area shape="RECT" coords="445,12,468,102"> <area shape="RECT" coords="430,17,434,21"> </MAP><BR>

<BR><BR>

<BUTTON onclick=Add2Options>Add to option (index 1)</BUTTON><BR> <SELECT id=selects> <OPTION>aaa</OPTION> <OPTION>bbb</OPTION> </SELECT> <BR>

</BODY> </HTML>

<div class="references_section">