Michael Rumpler

Hi,

I already posted this question to microsoft.public.internetexplorer.general 2 weeks ago, but got no answer. I'm not sure if I'm right here, but I'll try.

I have to change the backgroundColor of a dropdownlist on focus. And if you
leave it (onblur), the color has to change back again. Unfortunatelly IE7
closes the DDL when you change the cssClass or style.backgroundColor

You can see it easily with this html page:

<script language="javascript">

function SetClass(obj, valid)
{
window.status = 'Gonna change backgroundColor ...';

window.setTimeout(function() {
if(valid)
{
obj.style.backgroundColor = "green";
}
else
{
obj.style.backgroundColor = "red";
}
window.status = 'Changed backgroundColor';
}, 2000);
}

</script>

<select name="DDL1" id="DDL1" onblur="SetClass(this, true)"
onfocus="SetClass(this, false)">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</select>


I wanted to do only the if(){} part in the function. The window.status and
setTimeout is only to show better, when the DDL is closed again.

When you click the DDL, it is opened and all list items are shown. Two
seconds later, the backgroundColor is changed. This closes the DDL in IE7. In
IE6 and Firefox this works and the DDL remains open.

Has anybody seen this problem Is it a known bug Will it be changed

Thanks,
Michael



Re: Internet Explorer Web Development IE7 closes dropdownlist if style changed via javascript

Wesley Brandi - MSFT

Hello,

Just letting you know that I have confirmed the behaviour you are seeing. Changing the background colour using javascript through the onfocus/onclick event does not cause the drop down list to close when using IE6. The behaviour does seem to have changed on IE7.

I will look into this a bit more and get back to you as soon as possible.

Regards,

Wesley





Re: Internet Explorer Web Development IE7 closes dropdownlist if style changed via javascript

Wesley Brandi - MSFT

Hello again,

This bug has been logged and will be filed for consideration in a future release. In the meantime, although the following suggestion is not a perfect alternative it may help as a workaround: simply use the onmousedown event in place of the onclick/onfocus event. I have confirmed that using onmousedown to change the background colour of the control in IE 7 does not close the drop down list.

Hopefully this works for you.

Regards,

Wesley





Re: Internet Explorer Web Development IE7 closes dropdownlist if style changed via javascript

Kun Cong - MSFT

Current SELECT design forces dropdown to be closed up when style or content changed. We're considering improvement in next version.



Re: Internet Explorer Web Development IE7 closes dropdownlist if style changed via javascript

Michael Rumpler

Thanks. I'm not sure if onmousedown will help. The colour should be changed if you activate the DDL per keyboard (tab) too. Anyway, I'll try it.

Cheers,

Michael





Re: Internet Explorer Web Development IE7 closes dropdownlist if style changed via javascript

javanui

Try using the onfocusin event instead of the onfocus to call SetClass





Re: Internet Explorer Web Development IE7 closes dropdownlist if style changed via javascript

Jorn T

Hi,

This bug also occured for me in my recent project, but onmousedown worked just fine as a bypass. Thanks a lot.

Regards,

Jorn