Tuesday, April 04, 2006

Dynamically Changing Classes

Internet Explorer doesn't notice a fucking thing.

Say I have the following:
<div class="thin">stuff</div>
and I want to using unintrusive JavaScript to change it to this:
<div class="wide">stuff</div>
I would hope that would work fine, like it does for every other browser, but Internet Explorer simply ignores it.

Well, I suppose it does notice the class change - if I call (the element in question).getAttribute('class') it returns the correct value. I just completely fucking ignores all styles associated with that class.

I've tried a number of "cheats" to try tricking Internet Explorer into doing the useful thing:
  1. (the element in question).innerHTML = '' + (the element in question).innerHTML
  2. re-setting the stylesheet in question
  3. even looping through the stylesheets, disabling them and then enabling them after a short timeout to make sure they turn off in the first place
No change.

So thanks to Internet Explorer, I now get to get several blocks of "IE blows fucking chunks and I have to write this load of JavaScript when a single class swap should do the trick" instead of moving on to something else to get this project done.

Labels: ,