October 3rd, 2005

IE assumes .CSV is HTML, Firefox and Opera get it right.

Sooo… I posted that .csv (comma-separated values) file containing some benchmarks as part of my previous post on the performance differences between browsers when populating multiple select boxes in 2 different ways. What I didn’t notice until later, though, is that that file looks like crap if you click the link to it in Internet Explorer. IE seems to make an assumption like “Hmm, it doesn’t have extension ‘.txt’, so it must be HTML!” and it renders it as such. Of course, this .csv file doesn’t contain any HTML tags, so it doesn’t look pretty when IE makes that assumption:
MultiSelectPerformance.csv

For comparison, I made 2 copies of the CSV file:
MultiSelectPerformance.csv.txt
MultiSelectPerformance.csv.html

When I tried clicking the original .csv file link in Firefox and in Opera 8.5, they both behaved as I believe they should. They asked me if I wanted to open the .csv file with the application that is registered in Windows to handle files with that extension, Microsoft Excel, or if I wanted to save it to disk, or cancel.

Screenshots of those dialogs:

Firefox CSV file open dialog Opera CSV file open dialog

It strikes me as odd that IE, with its litigiously tight integration with Windows, didn’t bother to check the Windows File Types list before jumping to the strange conclusion that .CSV is a typo for .HTML. It’s possible that I could change my web server config files so it would send an appropriate ‘Content-type:’ header when .CSV files are served. But screw that, this is a stupid behavior in one browser, and I may want to serve a .CSV file on a web server someday where I can’t touch the config files. I was determined to do something to handle it on the client side.

[to be continued…]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>