IE7 – Webbrowser Control breaks select tag functionality

Found a real frustrating one today:

My application is a blend between a web app and an actual windows form application. You can either access the web app or the windows form app. A few of the more complex features are only available to you if you run the windows form app.

To share features between the two, I just embedded a web browser control on a tab, and I have it bring up the web application.

Everything has always worked great, until I upgraded a test machine to IE7. Turns out all of my dropdown boxes (select tags) inside the application’s web browser control stopped working.

So, to recap, my dropdowns work in IE7, IE6, Firefox, but they don’t work inside my application which is using IE7′s Web Browser Control.

I found the offending piece of code that I had to remove. We were doing a little style to the select boxes when you clicked on them, apparently this version of IE7 did not like it.

Offending Code:

function colorChanger(obj)
{
if (obj.style.backgroundColor == '#f00')
{
return true;
}
else
{
if (obj.style.backgroundColor == '')
{
obj.style.backgroundColor = "#eeeeee";
}
else
{
obj.style.backgroundColor=(obj.style.backgroundColor=="#ffffff"?"#eeeeee":"#ffffff");
}
}
}

I used this code like this: