Should we stop using iframes in IE?
In November last year, Aleksandar Vacić wrote his post Insert HTML page into another HTML page (found through No more iframes?). Basically, what it is about is finding a way to use an object element instead of an iframe to get the correct behavior in Internet Explorer.
Right about now, I guess your questions are why, how and is it necessary?
Why?
Internet Explorer doesn’t support using object elements the way they’re supposed to; for including content from another URL, an image and similar things. And the reason for not wanting to use an iframeis that iframe elements aren’t allowed in any strict doctype, be it HTML or XHTML (and really, you should definitely use a strict doctype). So, the initial motivator for Aleksandar is to have completely valid code.
How?
What he did was finding the classid in IE associated with iframe elements, and simply added that to an object element, and voilà ! His suggestion is to use conditional comments to serve an object with classid to IE, and a regular one to web browsers properly supporting object elements. Personally, I’d rather do this distinction on the server-side, but that’s up to you.
Is this necessary?
First, let me applaud Aleksandar for finding this method. It is exactly the kind of thinking outside the box that I admire and respect! However, I’m not sure this is the path to go, and I also wonder if the hunt for just valid code has gone too far. Since IE still doesn’t support object for these things, I’m just thinking that maybe one validation error isn’t that bad.
I mean, maybe this works just fine in IE, but having worked with Microsoft products for a long time, I’m just wary that some kind of security update or something like that will one day suddenly kill this behavior. Even though it seems to work fine in the test cases I’ve seen, you never know when web browsers turn on you…
So, at the end of the day, I don’t think I will use this, but if you want to, go crazy!
What’s your take?
Am I just worrying too much, or is my gut instinct the safest way to go?


