It keeps me up nights
It’s now 1:57 in the AM and I have fixed the problem I was having with Internet Explorer, including IE7 Beta 3. Basically, IE was loading a blank white page, and it was quite perplexing. I could view source and it was all there; I tried removing all PNG files and it didn’t help; I even went so far as to include Microsoft’s non-validating comments code in order to load an extremely basic stylesheet for IE alone, and I still couldn’t get anything to display.
(As an aside, I think it’s interesting to note Microsoft’s inclusion of this non-standard comments code, which provides for ‘if’ statements involving whether or not a client is using IE. On the one hand it’s kind of a nifty inclusion, but on the other, anything that you wish to hide from IE and leave exposed to other browsers requires the use of code that doesn’t validate. Then there’s the fact that their browser is so shitty as to force the use of such hackish techniques. It’s a total cop-out on the part of a bunch of lazy assholes, and in the end it just makes web developers angry. Way to go Redmond.)
Anyway, I started going through the code sequentially in attempt to figure out what it was I’d added to break things so badly in IE while leaving other browsers fat and happy. Then I remembered the style switcher; was that screwing things up? Given I didn’t even write the javascript for the thing, I was skeptical, but I tried commenting out the script tag in the site’s header and eureka! The damn thing loads in Internet Explorer, replete with the colorful (a.k.a. god-awful) theme I’d applied as a custom stylesheet in an attempt to coax the browser into showing me something.
As it turns out, it was technically a bug in my code. After a bit of post-solution Googling, I discovered that the script tag should not be self-closing. A more detailed explanation can be read here. In any case, the relevant code is now formatted as follows:
<script language="javascript" type="text/javascript" src="styleswitcher.js"></script>
And everyone’s happy! That is, unless you consider IE 6’s inability to render PNG transparency a cause of unhappiness, in which case I’d suggest that you either get yourself a new fucking browser or learn to live with disappointment.



Comments
There is in fact a cleaner way. You can have different style sheets for say IE and the rest, and use a server-side rewrite rule to send a different CSS file depending on the client’s User-Agent string.
Jean-Francois Roy on 07/18/06 at 9:32AM