Email Issues

A number of people have reported problems with the email processing on this site. I am happy to report that I have finally figured out the cause of the problem ... (more)

The Object Tag

There are a number of things that would be much easier to do on the web if it weren't for the significant number of people who still use browsers that do not come remotely close to properly following the current web standards. It is not like the browser writers are chasing a constantly moving target either since the current standards have been in place now for over 10 years with little change which is basically forever in web terms.The non-compliant browser that I am talking about is of course Internet Explorer since that browser actually dominated the market for several years before much better browsers appeared and started to steal the market from them.

A case in point is the iframe tag. This tag has been deprecated in the standards ever since the current standards were introduced in 1997. The tag is actually completely redundant since the object tag is supposed to be able to do all of what that tag can do and also a lot more.

The problem is that Internet Explorer has never implemented the object tag properly according to the standards. For one thing, unlike all other browsers, Internet Explorer 6 requires an additional field called a classid field in order for it to know what type of object it is supposed to be processing. The MIME type is sufficient for all other browsers but not for IE6. We can of course get around this problem by nesting one object tag inside another since if the outer object tag can't be understood then the content of the tag is supposed to be processed instead.

The problem there is that Internet Explorer 6 doesn't understand nested object tags and tries to process them both. We can get around this second problem by using Microsoft's conditional comments to hide the inner object tag from IE6.

So with this in place we can at last set up nested object tags that can load a separate web page into our page just like the deprecated iframe tag can with the difference being that we are not using any deprecated or invalid code and so we can use a strict doctype.

The problems with IE haven't ended there though since unlike other browsers IE insists on drawing a border around the object and placing the object in front of everything else on the page as well as popping up completely inappropriate security alerts. There is nothing that we can do about the border so far as the page that contains the object is concerned but if we apply a zero width border to the html and body tags in the page being called then Internet Explorer 6 will hide the borders properly for us. This limits us to attaching pages where we have control over the styles applied in the page being loaded into the object since without setting the border and also adjusting the overflow property on those elements of the contained page we end up with a border and scrollbar on our object in IE6. IE7 and IE8 don't have the issue with displaying an unwanted scrollbar but unlike IE6 there appears to be no way to turn off the border. I suppose we'll just have to live with the border in those browsers.

The other difficulty of always displaying in front of everything else also appears to have no solution (except to position your objects where you know that you will never want anything else to be able to move in front of them. Unlike with objects containing Flash where the wmode param can be set to opaque or transparent in order to allow other elements to move in front of the object, adding that param to an object trying to display HTML just stops the object from working at all.

The final issue with internet Explorer is that if the web page to be displayed in the object is from a different site then IE pops up a security alert advising you that the page will be displaying things not under your control. This would possibly make sense if IE did it for all methods of embedding other content in your page but it only displays the alert when you use the standard compliant method which is certainly no less secure than their proprietary methods are.

Why not a JavaScript solution? Well to start with not everyone has JavaScript and so a solution involving JavaScript would mean that the page doesn't work for everyone. In any case the simplest way to incorporate a page within a page using JavaScript is to forget about the object tag completely and instead just use Ajax to call a server script to retrie ve the appropriate content from the other page to insert into a div tag within the current page.

These limitations aside, we can get the object tag to work to display a web page within a web page subject to the above factors. The following are thw two alternative ways that I have come up with for coding this which work properly in all browsers except IE and which only suffer from the problems mentioned above in IE. Depending on exactly what you are trying to do these limitations on how IE processes the code may not affect what you are trying to do in any case and so the following mmay be a suitable alternative to using deprecated or proprietary tags.

First let's look at a version that uses conditional comments to supply one IE proprietary object tag to IE6 and earlier and a second standards compliant object tag to other browsers (including IE7 and later).

<!--[if lte IE 6]>
<object classid="CLSID:25336920-03F9-11CF-8FD0-00AA00686F13"
data="xiframe.htm" style="height:200px; width:200px; overflow:hidden;">
</object>
<![endif]-->
<!--[if gte IE 7]><!-->
<object type="text/html" data="xiframe.htm"
style="height:200px; width:200px;">
<p>Alternate text.</p>
</object>
<!--><![endif]-->
</object>

The second alternative nests the object tags so that browsers that don't understand the outer IE proprietary version will ignore it and process the one inside it. We then just need conditional comments to hide the inner object tag from those browsers that don't follow the standards and ignore the inner object when they can process the outer one (IE6 and earlier). This results in shorter code.

<object classid="CLSID:25336920-03F9-11CF-8FD0-00AA00686F13"
data="xiframe.htm" style="height:200px; width:200px; overflow:hidden;">
<!--[if gte IE 7]><!-->
<object type="text/html" data="xiframe.htm"
style="height:200px; width:200px;">
<p>Alternate text.</p>
</object>
<!--><![endif]-->
</object>

Note that I have also added html, body {overflow:hidden; border:0;} to the stylesheet of the xiframe.htm page in order to tell IE6 not to display a border and scrollbars around the object.

Here's what the two objects look like in the browser you are using. As you can see they appear identical to one another which indicates that it doesn't matter which of the two object tags that IE7 and later actually run.

Alternate text.

Alternate text.

go to top

FaceBook Follow
Twitter Follow
Donate