Some possible methods of embedding TIFF files in HTML documents are demonstrated below.
The examples assume you have a TIFF document accessible at the relative URL "tiffdocument.tif". To demonstrate how to pass parameters (when possible), we show how to tell AlternaTIFF to display a photo-negative of the image. The examples with a green background are the ones we consider to be the best choices.
You should also make sure your web server is configured to assign the MIME type "image/tiff" to your TIFF files. Most web servers will do this by default.
This document also includes a section on auto-installing into IE.
The simplest and most reliable method is probably just to use the embed tag. However, embed is not a standard HTML element (prior to HTML 5).
Make sure to include width, height, and src attributes. The type attribute is optional but recommended.
HTML code | How your browser handles it |
---|---|
<embed width=200 height=200 src="tiffdocument.tif" type="image/tiff" negative=yes> |
Refer to Microsoft's documentation.
HTML code | How your browser handles it |
---|---|
<script src="embed.js"></script> embed.js: document.write('<embed width=200 height=200 ' + 'src="tiffdocument.tif" type="image/tiff" ' + 'negative=yes>') |
This may be the most popular way to embed plug-ins and ActiveX controls in web pages. It's bloated and nonstandard, but it works with almost any browser. Note that this will force Internet Explorer to use AlternaTIFF if it is installed, even if it isn't the default TIFF viewer.
HTML code | How your browser handles it |
---|---|
<object width=200 height=200 classid="CLSID:106E49CF-797A-11D2-81A2-00E02C015623"> <param name="src" value="tiffdocument.tif"> <param name="negative" value="yes"> <embed width=200 height=200 src="tiffdocument.tif" type="image/tiff" negative=yes> </object> |
You can try to cover all bases by putting the URL in both a "data" attribute and a "<param>" element. The result is syntactically valid, and seems to work well enough in current web browsers. But there may be subtle problems with it, and it may not work at all in older web browsers.
HTML code | How your browser handles it |
---|---|
<object width=200 height=200 data="tiffdocument.tif" type="image/tiff"> <param name="src" value="tiffdocument.tif"> <param name="negative" value="yes"> </object> |
The object element works best in IE when you include a classid attribute, which is the unique identifier of the control you want to use. This method will force your visitors to use AlternaTIFF, even if they have another TIFF viewer installed. It's unlikely to work in browsers other than IE.
HTML code | How your browser handles it |
---|---|
<object width=200 height=200 classid="CLSID:106E49CF-797A-11D2-81A2-00E02C015623"> <param name="src" value="tiffdocument.tif"> <param name="negative" value="yes"> </object> |
This method is not recommended, because too many browsers fail to follow the standard. As of this writing, it does not work in IE.
HTML code | How your browser handles it |
---|---|
<object width=200 height=200 data="tiffdocument.tif" type="image/tiff"> <param name="negative" value="yes"> </object> |
Using frames is easy, but it prevents you from passing parameters to AlternaTIFF, may make scripting more difficult or impossible, and can lead to other problems.
HTML code | How your browser handles it |
---|---|
<iframe width=200 height=200 src="tiffdocument.tif"></iframe> |
Some browsers support TIFF images in <img> tags, though they usually won't use a plug-in in this case.
HTML code | How your browser handles it |
---|---|
<img width=200 height=200 src="tiffdocument.tif" alt=""> |
<object classid="CLSID:106E49CF-797A-11D2-81A2-00E02C015623" codebase="alttiff.cab#version=1,5,0,1"> </object>Replace "alttiff.cab" with whatever you named the CAB file. The "version" tag should reflect the minimum version that is supported by your web site. If the visitor already has AlternaTIFF installed, IE will attempt to upgrade it if it is older than the version you specify. To translate an AlternaTIFF version number into the format used here, replace the periods with commas, and append ",1" to the end.