I’ve been playing with the OBJECT element, which has been around for ages, but was never much used because Netscape 4 didn’t support it. I don’t care about Netscape 4, but I do care about Internet Explorer for Windows. Here’s my problem:

I want to replace the IMG element. Why, you ask? Because I’m a markup wanker who won’t leave well enough alone. Also, IMG has been removed from XHTML 2.0, in favor of OBJECT, and I’m wondering if there’s a smooth migration path. The question of the day is: Can we start using OBJECT now to replace IMG?

This is old-style markup:

<img src="http://diveintomark.org/public/2002/07/beagle-gimli.jpg" alt="A beagle sitting in a woman's lap" width="152" height="160" />

Which produces this image:

A beagle sitting in a woman's lap

This is new-style markup:

<object type="image/jpeg" data="http://diveintomark.org/public/2002/07/beagle-gimli.jpg" width="152" height="160">A beagle sitting in a woman's lap</object>

Which produces this image:

A beagle sitting in a woman’s lap

I think the parallels speak for themselves. My problem is with Internet Explorer. (There may be other problems with other browsers that I don’t know about yet. Leave messages in the comments if you can’t see this image at all.) The IMG-based image and the OBJECT-based image look identical in Mozilla and Opera. However, in Internet Explorer for Windows, the OBJECT-based image has internal padding within the OBJECT. Since the image is the same size as the OBJECT, this means we get ugly scroll bars. There is also a visible border around the OBJECT.

Now, I know a little about CSS, but none of the obvious tricks to get rid of this padding or border have worked. Searching Google for information about the OBJECT element is almost fruitless, since object is a very generic term, and all of the examples focus on embedding multimedia or Java objects. For example, here is the MSDN documentation on OBJECT, which notes both a BORDER attribute and a border style property, neither of which removes the visible border, and a full complement of padding style properties, none of which remove the padding.

Basically, nobody actually uses the OBJECT element this way (because IMG is easier and more direct, and also possibly because it doesn’t work in Internet Explorer — that’s what I want to find out), but if the W3C gets its way, everyone will in the future.

Update: thanks to several commenters, I have found these references:

Update #2:: in case I’m a wanker who can’t leave well enough alone is not a good enough explanation for you, this comment goes into more depth about why I am bothering.

§

Sixty six comments here (latest comments)

  1. Mark…

    FWIW, both images appear fine on IE5.2 for Mac as well as in Mozilla/Netscape variants on that platform. I’ve only got Version 5.0 of Opera on Mac but it works there as well.

    So this sounds like an IE Windows-specific problem from here.

    — Dan Shafer #

  2. There are problems with the alternative text and OBJECT as well.

    Neither Opera 7.10 (build 2840) nor Phoenix (last nightly build) display the alternative text for the image produced by OBJECT when images are disabled, and MSIE will display the OBJECT image even with images completely disabled. (All browsers tested on WinXP)

    I don’t think browsers are ready for OBJECT yet.

    — Jor #

  3. Also, the OBJECT element doesn’t allow for LONGDESC functionality.

    Incidentally, I think the HTML Working Group is nuts for wanting to take IMG out.

    –Kynn

    — Kynn #

  4. Is there a timeline for when they expect XHTML 2 to actually be adopted?

    — Ross #

  5. I’m wondering why I can select the IMG one, but not the OBJECT one (in Mozilla 1.3). If I paste it in Word for example, the Img is pasted as image, the Object is pasted as HTML code. So it’s not quite all right in Mozilla neither I think.

    — Anonymous #

  6. Mark, awhile back I went on the exact same quest for knowledge about how to get rid of the padding in IEwin. It was totally fruitless. There is neither a CSS nor proprietary MSHTML solution.

    A possible solution might involve using an ActiveX control. SWF files don’t have the padding right? So perhaps there is an ActiveX control you can use with the Object tag.

    Problem, however, is that currently Mozilla chokes when the classid attribute is used in an Object tag. Mozilla 1.4 is supposed to fix this problem from what I’ve heard.

    The Object tag, so elegantly designed to be degradeable in older browsers was spoiled a long time ago. What a shame.

    Anyways, simply setting an image as the background of a DIV seems to be the pragmatic solution to dropping the img tag at the moment. Zeldman had a write-up about it last month.

    or

    you can use conditional IE statements to produce pages that should still validate (the img tag being commented out to all browsers but IE).

    or

    you can wait until its actually practical to use XHTML. You’re the one who reverted back to HTML 4.01 so do you really want to travel back down this road again so soon? It can only result in needless frustration.

    — MikeyC #

  7. Ignoring the whole “yeah right whatever” nature of XHTML, I’ll note that Safari handles the above fine, but NetNewsWire Lite only shows the first image in the feed, though the second one gives a grey box. It gets the size of the box right, so I’d guess it is parsing it somewhat…

    — Mark Eichin #

  8. http://lists.w3.org/Archives/Public/w3c-wai-ig/2002AprJun/0865.html

    — Ron Green #

  9. Dan, Jor, Kynn, and everyone else who knows more about OBJECT than I do: thank you. All of this is very helpful.

    I will likely be incorporating these comments into an upcoming XML.com article (possibly this week like I promised last month, possibly next month). Many of the things we “lose” in XHTML 2.0 are easily replaced or worked around. IMG –> OBJECT and forms –> XForms are the 2 big stumbling blocks, I think.

    — Mark #

  10. For some reason, in Apple’s HTML component (as used in NetNewsWire), the object version shows up as a big gray square. This probably isn’t a showstopper, but it is sort of weird that it knows enough to render it as a square, but doesn’t fetch the image.

    Maybe it’s looking for a src attribute and not a data one?

    — Aaron Swartz #

  11. Mark, here is another possible solution.
    It seems that IEwin will only accept "image/jpeg" and not "image/jpg" for the type attribute.
    Therefore:
    <object type="image/jpg" data="example.jpg" width="100" height="100">
    <div id="stupidIE"></div>
    </object>
    Where #stupidIE has a background-image of "example.jpg".
    or
    <object type="image/jpg" data="example.jpg" width="100" height="100">
    <!–[if expression]>
    <img src="example.jpg" width="" height="" />
    <![endif]–>
    </object>
    note: conditional statements are optional. I included them if its necessary to "fool" the validator.
    or
    <object type="image/jpg" data="example.jpg" width="100" height="100">
    Your browser does not support the Object tag. Boo hoo.
    </object>

    — MikeyC #

  12. Thanks Mark. Looking forward to the article.

    I’ve done a bit more testing, and Opera 7 has a similar problem like Mozilla does as described in comment #5 — the ‘Image Popup Menu’ is not called, in fact, no context menu at all appears.

    This means it is not possible to copy the image or even the image URL. If the object is a link, only the link context menu appears.

    Opera appears to handle all objects like plugins, even those that are handled internally (and thus cannot be disabled by disabling plugins!).

    — Jor #

  13. This just goes to show how much Internet Explorer is holding back the rest of the Internet. (As if we needed *more* proof.)

    — nachomama #

  14. http://www.alistapart.com/stories/flashsatay/ is all about using objects for Flash movies. His findings should also apply to images and other media.

    — Jan! #

  15. I think I’ll just stay with my img tags.

    — noel #

  16. MikeyC: if we’re going to do background images, we may as well skip OBJECT altogether and do the Fahrner Image Replacement. For those who don’t know what this is, here are some links:

    - http://www.stopdesign.com/articles/css/replace-text/
    - http://www.stopdesign.com/log/default.asp?date=20030313
    - http://www.stopdesign.com/log/default.asp?date=20030314
    - http://www.zeldman.com/daily/0203c.shtml#cssbgben
    - http://www.zeldman.com/daily/0203c.shtml#cssbg

    — Mark #

  17. Using backgrounds for images is unsuitable for any meaningful images. There is no decent way of falling back (the “guiltless image use” article already mentions some of them).

    Going to <object> would be nice, I investigated this some time ago. Unfortunately, the fallbacks don’t work as they should in a lot of browsers, and the rendering is nasty in IE.

    The reason for dropping <img> is that it doesn’t really do anything. It’s merely a specialisation of <object> that is less capable. The only reason people are so attached to it is because they have been using it so long.

    Now, ignoring user-agent bugs (which we can, since XHTML2 isn’t final, let alone implemented by any user-agents), and ignoring backwards compatibility (because XHTML2 is explicitly not backwards-compatible), is there any justification for keeping the <img> element?

    — Jim #

  18. Re: going down this road again. Hey, I admitted to being a markup wanker. What more do you want?

    Long answer: I initially gave up on XHTML 2.0 because of its intentional (and in some cases, seemingly spiteful) backward incompatibility. I was convinced that people would need a migration path in order to adopt it, and that there was no such migration path. I still believe the former, but I am no longer convinced of the latter. I am working through individual issues (like this one) to explore what such a migration path would look like.

    All the work I have seen so far in the XHTML 2.0 world has been about what it would be like to *be* there. Which makes sense, since it’s not finished yet and they’re still hashing out the details. However, there has been a distressing lack of information about what it will take to *get* there, from where we are now. Even assuming that where we are now is “valid XHTML 1, used properly” (a huge assumption for most sites), there is *still* no information about how to make the leap from there to XHTML 2.

    Members of the HTML Working Group seem totally unconcerned with this. They have indicated publicly (on www-html and elsewhere) that they see no need for a migration path from XHTML 1 to XHTML 2. XHTML 2 is for new documents, they say, and no one will bother converting existing documents and applications.

    Bluntly, I believe they are full of shit.

    Experience has shown us that there *is* a natural demand for the latest and greatest, if only out of fear. Developers see “XHTML 2″ and assume that it is a replacement for “XHTML 1″, and they fear that if they only know “XHTML 1″, HR departments will soon start rejecting their resumes because they are filtering on “XHTML 2″. As I have pointed out before, this assumption is incorrect (at least the part about it being a replacement — the part about HR departments is probably true), but the HTML Working Group seems determined to further misconceptions about this new markup language (which is explicitly *not* a replacement for XHTML 1, and which is explicitly *not* compatible with XHTML 1) by giving it the same name, the next major version number, and the same MIME type.

    So, the question I’m trying to answer is: “Assume XHTML 2 takes off. Given what I know now and what my documents look like now, how fucked will I be when prospective employer asks what I know about this newfangled XHTML 2 thing? Or when a client comes to me and demands XHTML 2 compliance?” I am attempting to answer this question by positing a hypothetical developer trying to “future-proof” documents and practices now. Some things are simply radically different (like forms), but with other things, there are ways to do things now that will directly translate into an XHTML 2 world. If There’s More Than One Way To Do It, some ways are better than others.

    What if a client comes to you and says “I want XHTML 2 for newer clients that support it, and XHTML 1 for older clients.” How do you do that? Saying “the world doesn’t work like that, it’s all or nothing” isn’t a helpful answer. You better find a way to make the world work like that, or the client will go somewhere else. I think this is a likely scenario, since it is likely that XHTML 2 will someday have desirable features that are not backported to XHTML 1. Even assuming you’ve got all your raw content separated from your markup, you’ll need equivalency maps to make both sets of output transformations. The closer those transformations can be to each other, the easier they will be to test, debug, and maintain.

    — Mark #

  19. Hi Mark,

    the problem ist that IE handles object tags the way that it renders its data with another IE instance if no classid for an active-x component is given.
    what happens if you just load your image alone in your IE? right the same white borders and no way to influence anything because you don’t load any markup.
    there is one way to get around that, just delete the height and width parameters of your object tag and all is fine.

    best regards, andi

    ps.: also don’t define width and height via css.

    — Andi #

  20. Andi, if I delete my width and height parameters, IE 6 shows me nothing at all.

    — Mark #

  21. sad, i was using IE 5.0 :-(

    — Andi #

  22. anyway, the problems is the component which renders the object tag.
    another solution could be using png as you can see in this example: http://www.libpng.org/pub/png/pngs-bg.html

    — Andi #

  23. on my machine quicktime renders png’s.

    — Andi #

  24. It might also be worth mentioning that IE/Win has a problem with PNG images as objects: it doesn’t display them. Rather, it displays the “fallback” content.

    It would be a shame to forever ignore such a versatile element because one browser–even it that browser is the most popular one–fails to properly support it. Perhaps we can use the lack of backwards-compatibility in XHTML 2.0 to our advantage here, assuming Microsoft can be convinced to fix their implementation of the object element for XHTML 2.0 documents.

    — Greg H. #

  25. Opera 7 treats ‘object’ now like ‘iframe’. I have iframes disabled most of the time, because they are often used for ads. Thus I can’t see the content of the ‘object’ element. In Opera 6 for Windows I see it.
    Hmmm…

    — Thomas Scholz #

  26. “Assume XHTML 2 takes off. Given what I know now and what my documents look like now, how fucked will I be when a client comes to me and demands XHTML 2 compliance?”

    I think any client that knows enough to ask for “XHTML 2″ would probably know enough about the realities of implementing it given the state of browser support (yes this is a big assumption I am probably wrong about).

    But, I’ve never had a client come to me and ask for “HTML 4.01″ or “HTML 3.2″ or anything else of that nature. I *have* had clients ask for things that simply weren’t possible like embedding fonts in a cross-browser/cross-platform way in HTML documents. That’s the kind of stuff that clients ask for. But its the developer’s job, at that point, to explain to the client why it isn’t possible/practical.

    Quite frankly, I have never encountered a client who has said a word about standards-compliance, so even if they asked for “XHTML 2.0″, you could probably just go ahead and use the IMG tag anyways (as evil as that may be). Lets get real for a moment: no browser maker in their right mind is going to strictly enforce XML syntax in their product without a fallback “loose” rendering mode (I think you touched upon this in your last article on malformed rss feeds). It just ain’t gonna happen. The future belongs to “million-dollar programming” (like Opera’s small-screen rendering) and not “million-dollar mark-up”.

    Don’t get me wrong: This isn’t necessarily how I think things *should* be, but simply how I see things unfolding.

    HTML is dirty and XHTML will be just as dirty.

    — MikeyC #

  27. MikeyC…

    the funny thing about the markup that browsers will never enforce… makes me laugh each time. It’s just a question of doing it, not about legacy. When Netscape was unable to display table when the end tag was not here, all people have closed their tables. So when a browser enforce a rule people follow. If you have a new language which gives you to do that and respect the rules, you’ll see that people will follow it.

    Because as Mark and you said, people just want to see their page. So if having a stricter code make your page visible, people will do.

    — karl #

  28. Sorry about the previous double post…
    Anyways, here’s another possible "solution".
    Ok…IE will display SVG without the padding (this may rely on the Adobe SVG plugin being installed…i didn’t try uninstalling it for this test) which means you can embed your image in an SVG file. OpenOffice will let you do this among other programs. Mozilla/Opera(?) as yet do not support SVG so we have a nested Object tag providing a jpeg version to those browsers.
    IE, however, doesn’t respect the "cascade" of the Object tag and simply places nested Objects next to their parents (which, by the way, is why we are forced to use the embed tag for Flash files–not because of a Mozilla/Netscape/Opera deficiency, but to deal with IE’s finicky behaviour with regards to nesting) so we use IE conditional statements to hide the nested Object. This will not break the validity of the document, and is actually a clever feature that MS came up with to deal with the crappiness of their browser.

    <object type="image/svg+xml" data="beagle-gimli.svg" width="100" height="100">
    <![if !IE]>
    <object type="image/jpeg" data="beagle-gimli.jpg" width="100" height="100"></object>
    <![endif]>
    </object>

    This method should be both XHTML 2.0 compatible and work in most(?) modern browsers. I think you can even point to an external image file from an SVG document so the amount of duplication would be minimized to a small SVG "container" file. When Mozilla finally adds native SVG support (and Opera?) to the trunk we would be able to simplify the coding down to the parent Object alone.

    — Anonymous #

  29. “When Netscape was unable to display table when the end tag was not here, all people have closed their tables. So when a browser enforce a rule people follow.”

    Yeah, but that was during the time when Netscape had more than 3% marketshare. You know how many pages I encounter that break horribly in browsers other than IE due to bad HTML? A lot.

    — MikeyC #

  30. I’ve posted the example in #29.

    a couple things: first off, I wasn’t able to link to the jpeg (i think its possible to do so but I am not positive) so its embedded instead.

    Second off, the validator is telling me the IE conditional statements are invalid in that they are “not reserved words”. I recall reading somewhere that they should validate. So I don’t know if its the validator or the statements…

    Anyways, take a look:

    http://members.rogers.com/divx/object/

    Would be interested to hear from people who don’t have an SVG plugin installed in IE.

    — MikeyC #

  31. Lucas Thompson (trackback)
  32. >Second off, the validator is telling me the IE >conditional statements are invalid in that they >are “not reserved words”.

    • validator.w3.org says its an error.

    • HTML-Tidy says that the page is error-free XHTML strict.

    I’m not sure what the answer is. I do know that the validator isn’t always perfect…

    — MikeyC #

  33. Since the current support for object is so bad, isn’t it possible to take a XHTML 2 document and use XSLT to transform it into another version of XHTML / HTML with img’s for older browsers?

    — Peter Winnberg #

  34. I’m currently on a locked-down computer. I get a ActiveX security error and the image doesn’t show.

    — matt pusey #

  35. When viewing the object in Syndirella, it looks like a text area with scroll bars. No image appears.

    — Joshua Kaufman #

  36. The object version triggers the “Would you like to allow programs such as ActiveX controls to Run?” dialog. I have somewhat paranoid security settings; they help me avoid some of the evil active content out there (like automatically downloaded Gator software). So even though it has no code (it is just an image), IE warns me, and I almost always click “No” on that box.

    — Harald #

  37. To be fully consistent with the OBJECT/IMG tag distinction (comment #17, IMG as a specialized version of OBJECT), XHTML 2.x should eliminate all textual markup such as CODE, EM, CITE, and ACRONYM, which are in effect specialized versions of SPAN.

    I don’t think that’s quite feasible. IMG means, quite bluntly, “image”, and promotion of OBJECT leads to needless page bloat.

    — Andre #

  38. Getting in very late here, but MikeyC, Mark, there’s a huge problem with Fahrner (as referenced here – http://diveintomark.org/archives/2003/04/13/object_and_internet_explorer.html#c001221) in, get this, Mozilla-based browsers.

    No, really:

    http://www.mezzoblue.com/tests/mozilla-bg-bug/

    — Dave S. #

  39. No image at all on IE6/Win. :-(

    — Anonymous #

  40. Not sure on the might as well “do the Fahrner Image Replacement” technique. It’s mostly been used for typography and a few small decorative gifs, hasn’t it?

    I did try it awhile back with the content of what I was using for “longdesc” for a JPEG in the bit hidden with CSS, and putting the image (a 500×348 JPEG) in for CSS-reading graphical browsers with background-image. IE and Opera browsers distorted the photo horribly, cutting off the bottom and stretching it horizontally like some kind of wide-angle lens.

    — Michael #

  41. Another problem with is that IE (6 at least) doesn’t let you position anything over it.

    For instance, you can create a draggable on top of an , but you can’t do that over an

    — Ziad #

  42. Damn no HTML !
    Another problem with OBJECT is that IE (6 at least) doesn’t let you position anything over it.

    For instance, you can create a draggable DIV on top of an IMG, but you can’t do that over an OBJECT

    — Ziad #

  43. Andrew, (comment #38), those other tags have a special meaning, whereas image adds nothing special to its own definition. Also, object is a far better tag to use once it is feasible, rather than image because of its way of handling alternative content.

    Let’s face it, alt=”" is a hack, simple as that, whereas object allows you to have an image fallback within a flash movie, which itself has a fallback to several paragraphs describing the movie with a link for more information. Or whatever else you want to do.

    Mark, have you thought of having “comment #xx”s automatically turned into links to the appropriate comment?Not necfessary, but it’d be nice when you’re down at comment number 59 and someone references comment number 2, which you’ve forgotten by that time.

    — Lach #

  44. Sorry Andre, “Andrew” was a typo.

    — Lach #

  45. MikeyC, as for clients asking for XHTML 2, I should clarify: they won’t ask for XHTML 2 specifically, they’ll just ask for things that can only be done in XHTML 2. Again, this is theoretical, since the spec isn’t final and no such things exist yet. But I’m positing that they *will* exist. Remember, even if XHTML 2 isn’t a “replacement” for XHTML 1, it is the only language in the family that is evolving. Members of the HTML Working Group have stated publicly that there will be no XHTML 1.2. (And there sure as heck won’t be any HTML 5.)

    http://lists.w3.org/Archives/Public/www-html/2003Jan/0378.html

    So it is reasonable to assume that XHTML 2-only features are in our future. And even if the client doesn’t know that XHTML 2 is a prerequisite for the advanced features they want, you’ll be stuck trying to find some way to serve a dual site. Such a site will *have* to use some sort of server-side transformations (XSLT would be one choice), but obviously anything you can do to make those transformations easier to maintain will reduce your development costs.

    — Mark #

  46. anil dash's daily links (trackback)
  47. The example above puzzled me quite a bit (specifically the “new-style” example) until I discovered that the firewall/proxy in the office has stripped out the object tag completely. As far as I can make out it’s the data=”" bit that triggers the alarm bells. Just one more reason why the OBJECT tag isn’t much use right now.

    — Anonymous #

  48. I do not see what is so wrong about XHTML 2.0 being a major departure from 1.0.

    You argue that clients will demand XHTML 2.0 compliance. What?!! What clients even demand 1.0 compliance? Compliance is a largely web developer intitiated selling point on why they are, as a web developer, the web developer of choice!

    — James Head #

  49. Interesting experiment in IE 6:
    Assign an id value to the object element (I assume ‘newstyleimage’ in the following).

    Set the onLoad funtion to the following JavaScript:

    function fixPadding ()
    {
    newstyleimage.body.style.margin = ‘0′;
    newstyleimage.body.style.padding = ‘0′;
    }

    Explanation: Think of the object tag as an IFRAME.

    — John #

  50. John: if that works, that’s excellent. Now, can we expand that into a solution that doesn’t require the script to know the specific ID? I’m thinking of some unobtrusive Javascript (that we can just link in and call once) that finds all the OBJECTs on a page that are images (probably key off a list of common image MIME type) and does this to them automatically. Any takers?

    — Mark #

  51. James: as I have explained repeatedly, clients will not demand XHTML 2 compliance per se, but I strongly believe that there will eventually be web features which are XHTML 2-only, and clients will demand those (not realizing or caring that those features require XHTML 2).

    XHTML 1 is not expanding. HTML 4 is not expanding. Brooklyn is not expanding. The HTML Working Group has said publicly that there will be no XHTML 1.2, no HTML 5. All future innovations/specifications/modules/etc. coming out of the W3C will build on XHTML 2, not 1.

    Plus, there’s still the matter of HR departments demanding XHTML 2 knowledge. Don’t tell me *that* will never happen.

    — Mark #

  52. Mark,
    Don’t get too excited yet. Right now, I don’t know how to suppress the right scroll bar. Still not sure if this is useful or no. Oh, BTW newstyleimage.body.style.border = ‘none’; gets rid of the sunken border, so the pesky scrollbar is the remaining fly in the ointment.

    — John #

  53. use
    imageid.body.scroll = ‘no’
    in your script to remove the scrollbars

    — Anonymous #

  54. Progress!

    To remove borders and scroll bars, use this code:

    function fixPadding ()
    {
    newstyleimage.body.style.margin = ‘0′;
    newstyleimage.body.style.padding = ‘0′;
    newstyleimage.body.style.border = ‘none’;
    newstyleimage.body.style.overflow = ‘hidden’;
    }

    — John #

  55. This is the final hack. Works OK with IE6 (not tried with earlier versions. Interestingly the JavaScript doesn’t cause an error in Opera 7 or gecko (Phoenix 0.5 tested). Probably should sniff the newstyleimage.body value to see if not null.

    The code:

    function fixPadding ()
    {
    var objs = document.getElementsByTagName (’OBJECT’);
    for (n = 0; n = 0) || (strPath.indexOf(’.gif’) >= 0))
    {
    fixObject (obj);
    }
    }
    }
    }

    function fixObject (obj)
    {
    obj.style.margin = ‘0′;
    obj.body.style.padding = ‘0′;
    obj.body.style.border = ‘none’;
    obj.body.style.overflow = ‘hidden’;
    }
    // Only do this for IE !
    window.onload = fixPadding;

    Anyone got a better way to detect the image type? Sadly, IE doesn’t handle png images, so there is no test for them.

    — John #

  56. Sorry for previous posting — the greater than / less than chrs created a mess. Here is the code again (Why didn’t I preview it first?). And please note that the data path needs to be in your domain or you will get a ‘permission denied’ message.

    function fixPadding ()
    {
    var objs = document.getElementsByTagName (’OBJECT’);
    for (n = 0; n < objs.length; n++)
    {
    var obj = objs [n];
    if (obj != null && obj.data != null)
    {
    var strPath = obj.data;
    if ((strPath.indexOf(’.jpg’) >= 0) || (strPath.indexOf(’.gif’) >= 0))
    {
    fixObject (obj);
    }
    }
    }
    }

    function fixObject (obj)
    {
    obj.style.margin = ‘0′;
    obj.body.style.padding = ‘0′;
    obj.body.style.border = ‘none’;
    obj.body.style.overflow = ‘hidden’;
    }
    // Only do this for IE !
    window.onload = fixPadding;

    — Anonymous #

  57. if ( (obj.type == “image/jpeg”) || (obj.type == “image/gif”) ) {
    stuff();
    }

    should work, but untested

    — Anonymous #

  58. JD on MX (trackback)
  59. Anonymous,
    Yes, (obj.type == “image/jpeg”)etc. works nicely. Thanks.

    — John #

  60. asterisk* (trackback)
  61. anyone feel like posting a completed version of the script in use?

    — Anonymous #

  62. For all of you too busy (or lazy) to put the pieces together, here is the current version in full. Works (for me) on IE6 — and, interestingly, causes no error in gecko (Phoenix 0.5) or Opera 7. I guess a production version should sniff for (obj.body != null).

    <script type=”text/javascript”>
    function fixObjectImages ()
    {
    var objs = document.getElementsByTagName (’OBJECT’);
    for (n = 0; n < objs.length; n++)
    {
    var obj = objs [n];
    if ((obj != null && obj.type != null)
    && ((obj.type == “image/jpeg”) || (obj.type == “image/gif”)))
    {
    fixObject (obj);
    }
    }
    }

    function fixObject (obj)
    {
    obj.body.style.margin = ‘0′;
    obj.body.style.border = ‘none’;
    obj.body.style.overflow = ‘hidden’;
    }
    // To do: Only do this for IE !
    window.onload = fixObjectImages;
    </script>

    — John #

  63. I’ve been through this just like everyone else, unable to get IE to display images in OBJECT tags.

    If XHTML 2 was a current standard, then I’d be upset. But, XHTML 2 is in the draft stage, so what’s the big deal? There are things that aren’t supported in any browser that are part of XHTML 2, albeit browsers like Mozilla will probably let you style them nonetheless.

    I don’t know, this whole argument seems silly. If anyone started calling out the CSS 1 spec because certain features didn’t work in Netscape 4 they’d be laughed at, and CSS 1 is a SPEC, not a DRAFT. Oh well, maybe I missed something.

    — David #

  64. David Wrote: “If XHTML 2 was a current standard, then I’d be upset. But, XHTML 2 is in the draft stage, so what’s the big deal? …Oh well, maybe I missed something.”

    What you seem to be missing is that the Object tag isn’t something new that’s been designed for XHTML 2, but has been around for many years already and its an absolute shame that browser-makers messed up its potential by implementing it so poorly.

    — MikeyC #

  65. Even if MS fixes the behaviour of OBJECT in IE7 (if it ever comes out), about 40% of users are still using IE5 or older.

    So even with we assume that all IE6 users upgrade, 2 in every 5 web users will not be able to the images properly. Not good.

    — Neil T. #

  66. Reply to comment #2:
    Alternative text (and HTML) for the image produced by OBJECT *has* worked in earlier Opera versions, at least v6. Since Opera 7 was rewritten from scratch, I suppose it’s just been temporarily left out.

    — Björn Brändewall #

Respond privately

I am no longer accepting public comments on this post, but you can use this form to contact me privately. (Your message will not be published.)



§

firehosecodeplanet

© 2001–9 Mark Pilgrim