October 21, 2003
Worst. Tag. Ever.
"Rest assured, I was on the Internet within minutes, registering my disgust throughout the world."
So far, this week has not been a great week, technology-wise.
First, this week's award for Kookiest Third-Party Documentation goes to JUnit.org, for their rather creative Javadoc description for
TestSuite.createTest(). Umm, guys, the traditional we-don't-give-a-rat's-ass-about-our-Javadoc Javadoc would have been something like, "
TestSuite.createTest(): Creates a test." Better to be random and pointless than simply pointless, I suppose.
Second, a special shout-out to Dell for designing their hardware such that you can't buy 3rd-party memory. Let's see, $210 for two sticks of PC100 RAM. At least now my system can handle amazing feats of computational wizardry... such as running Netscape and FrameMaker at the same time.
But the real winner of this week's sweepstakes is the
<object> tag. The problems with this tag are well-known. Yes, it has terrible support in modern browsers. Yes, it is the only replacement for the
<img> tag in XHTML2... still. And no, the situation is not going to improve significantly until about the year 2006. But you've heard about all that. I'd like to share with you my particular episode of
<object> tag pain.
So how do you embed SVG in a web page? In theory, you could do it inline... if you served up a pure XHTML page with the right MIME-type, and a carefully constructed DOCTYPE, to the right browser, on every third Sabbath after Simchat Torah. But even the foolhardy don't bother with this strategy. No, the accepted method uses the
<object> tag, like so:
<object type="image/svg+xml" data="/path/to/image.svg" width="400" height="400"> <img src="/path/to/image.gif" width= "400" height="400" alt="description" /> </object>
<object> tage embeds the SVG image, while the old-fashioned
<img> tag provides a fallback GIF image for older browsers. Elegant, right? Only problem is that this markup crashes my copy of Safari every single time.
The problem is with the
type attribute, which specifies the MIME-type of the SVG file. If the attribute is present, Safari crashes. If you delete it, Safari works just fine, but IE 5.2 for Mac no longer displays the object. Apparently IE5.2 needs the MIME-type explicitly defined. (This might also be the case for IE/Win, but I haven't tested this yet.) Note that both browsers have interesting and quirky behavior. Safari is perfectly happy to display the SVG image if there is no
type attribute at all or a totally made-up value (such as "
foo/bar". However, a wrong MIME-type ("
text/html") causes Safari to A) not display the image and B) bring a Finder window to the foreground. (?!) IE5.2, on the other hand, refuses to display the object if the attribute is absent or if the MIME-type is totally made up... but it does display the image if you provide any MIME-type that it understands, such as
text/html. Meanwhile, Mozilla displays the image in all circumstances.
But don't fret! You know what works for all three browsers, every single time, with no crashing or quirks whatsoever?
<embed src="/path/to/image.svg" width="400" height="400">
Yeah, I need a drink too.