fUck IE6 (must die) [selector's]

Post date: Dec 11, 2008 7:44:22 PM

I was searching for solution on how to make fucking IE6 from fucking Melkosoft (must die) work with selectors and found that i'am not alone:

"

Presupposing these functions:

function addNewOption(select, value, label) {

var option = document.createElement("option");

option.setAttribute("value", value);

option.appendChild(document.createTextNode(label));

select.appendChild(option);

}

function getOptionIdx(select, value) {

if(!select.options) return -1;

for(var oNum = 0; oNum != select.options.length; oNum++) {

if(select.options[oNum].value == value) return oNum;

}

return -1;

}

Now watch carefully:

var optVal = "1";

var select = $("exampleSelect"); //prototype shortcut

addNewOption(select, optVal, "one");

This code retrieves a select by ID and adds an option to it. (The select is a single-value select.) The following code selects that option:

select.selectedIndex = getOptionIdx(select, optVal);

Or it would do, if it worked in IE. Apparently selectedIndex is readonly in IE4, which I don't care about. However, selectedIndex is also readonly in IE6, under certain circumstances, but it just fails silently. The workaround for the IE4 bug was as follows:

select.options[getOptionIdx(select, optVal)].selected = true;

This fails in IE6 with the stunningly unhelpful message "Could not set the selected property. Unspecified error."

HOWEVER, this code does work:

var optIdx = getOptionIdx(select, optVal);

alert("optIdx="+optIdx);

select.options[optIdx].selected = true; // [1]

Removing the alert (or logging statement or whatever) gets you straight back to square one. Wierder still, surrounding [1] with a try-catch block will throw an "undefined" error, and set the select to the value, which I guess is the workaround I need.

Needless to say, I don't have this problem on FireFox. My completely uneducated guess is that DOM tree operations are slightly asynchronous, and that the time it took for the JS interpreter to move onto the next instruction was longer than the time it took for the DOM update thread to finish making changes, when computers were slower than they are now. I have no idea.

Posted by Ian at 1:11 PM "

from here http://ianso.blogspot.com/2005/10/another-stupid-ie-bug-selectedindex-on.html

also for those who use jquery look here http://groups.google.com/group/jquery-en/browse_thread/thread/2902a4393f93df52?pli=1&auth=DQAAAHsAAABUwbmHP1QcEp7G6tVGwn-cCr5zj9G-7PfLVC38S5HbLhCtsEl_SvqQIkqzTRS6hY_4wjPANXv90GA12YpZT6vOKp1tOkNMhyfKcjQh6SQ3rcXD_p1hIwVXOAD4tFAFv3OMPZrH9ThYzP4gJy-9cDTSqUlqFkMkpJkHao1y4EVuow

I have fuck this fucking IE (stupid dunkey) errore

"

try{

select.optionsp[ optindex].selected = true;

}catch( fuckingException ){

//do nothing :-D

}

"

Ось така хуйня малята звесть всі продукти майкрософт (окрім мишок)

Мишки від майкрософт дуже класні.

ПС це єдине що я можу сказати доброго про майкрософт