dJIR: Dynamic JavaScript Image Replacement

What is this?

It is an image replacement technique that relies on JavaScript to replace text with a dynamic image. In some browsers, like Opera or Mozilla, it can dynamically resize the text, based on the user's settings. Otherwise, the PHP script for creating the text image tries its best to resize and wrap the text.

Where can I see it?

You're looking at it. All of the headlines found inside div#body are dynamically generated with our replaceText function. This code is strongly based on PPK's image replacement technique.

Improvements made from PPK's image replacement technique

How is this different from other image replacement solutions?

Where is a good place to use it?

Where is not a good place to use it?

Note: Using static images, rather than dynamically created images, is perfectly fine to use in any of these instances.

Other Examples

This is a Background Image, it works best on block elements

Requirements

What script would be complete without requirements?

The Source

Keep in mind that these files are subject to change at any time.

Files
Filename Purpose Last Modified
common.js Initializes our replacements Jan 09, 2006 11:19 EST
texttoimage.js Library to make convert text to images Feb 14, 2006 12:23 EST
class.maketext.php Creates the dynamic images (optional) Jan 18, 2010 17:15 EST

Browser Support

Tested Browsers
Browser Name Version Supported
Opera 8.x Yes
Opera 7.x Yes
Opera 6.x No
Mozilla 1.x Yes
Netscape 7.x Yes
Netscape 6.x Yes
Netscape 4.x No
Internet Explorer (Win) 6.0 Yes 1
Internet Explorer (Win) 5.0 Yes 1 2
Safari 1.x Yes 3

1 Internet Explorer does not calculate font-size to a pixel value, instead it sends the exact CSS specified values. This only matters if you are using dynamic images.

2 Internet Explorer 5.0 supports all of the javascript just fine. However, it does not properly support many of the CSS techniques used for hiding the text. Using replaceText is the preferred method for this version.

3 Safari is unable to determine certain CSS information necessary to pass to the dynamic image generating script.

Change Log

Credits