Journal

Archive for December, 2007.

24 ways… Transparent PNGs in Internet Explorer 6

Dec 20 | Posted by Jeffrey Barke | Add a Comment

For the past three years, 24 ways has been the Advent calendar of choice for web developers. This year started off with an excellent article and script by Drew McLellan dealing with PNGs in IE5.5 and 6.

If you work with PNGs or plan to, this is a very concise and informative article. It quickly describes how PNG transparency works, outlines the problem with IE 6 and below, provides a solution, and details the limitations of this solution. I really can't recommend it enough.

SuperSleight

As if this wasn't enough, Drew then introduces SuperSleight, a JavaScript that automates support for PNG transparency in IE5.5 and 6. Based on sleight by Aaron Boodman and bgsleight by Drew McLellan, "SuperSleight adds a number of new and useful features that have come from the day-to-day needs of working with PNGs."

  • Works with both inline and background images, replacing the need for both sleight and bgsleight.
  • Will automatically apply position: relative to links and form fields if they don’t already have position set. (Can be disabled.)
  • Can be run on the entire document, or just a selected part where you know the PNGs are. This is better for performance.
  • Detects background images set to no-repeat and sets the scaleMode to crop rather than scale.
  • Can be re-applied by any other JavaScript in the page—useful if new content has been loaded by an Ajax request.

Since we use PNGs quite a bit at theMechanism, SuperSleight was of great interest to us, particularly in the London office. When I looked at the code, however, there was one thing I didn't like—to change two of SuperSleight's properties required changing values hard-coded in the class. To change the third required a separate call to the limitTo method.

Enter theMechanism

To make SuperSleight easier to implement for my colleagues in London, I added three parameters to the init and run methods of the supersleight object. Our version of SuperSleight (which I'm calling 1.1.0) is available here and partial instructions on how to use it are below. The primary documentation on SuperSleight is still Drew's 24 Ways article. You can see SuperSleight 1.1.0 in action here.

How to Use

  1. Download SuperSleight and unzip. Upload supersleight.js and x.gif to your webserver.
  2. Add the following code to the <head> element of any page that contains PNGs:

<!--[if lte IE 6]>
<script type="text/javascript" src="path/to/supersleight.js"></script>
<![endif]–>

That's it! By default, SuperSleight will run on page load, look for a transparent GIF named x in the same directory as supersleight.js, apply relative positioning to anchor and input elements, and process every PNG on the page. To change any of these default behaviors, open supersleight.js and edit or remove line 17:

17. supersleight.init();

The init method of the supersleight object takes three optional parameters:

  1. String path to the transparent gif file. Note this path is relative to the actual document, not the JavaScript document.
  2. Boolean value to apply relative positioning to anchor and input elements. Pass false to leave the elements as they are.
  3. String ID of an element to limit SuperSleight's operations to.

To see these parameters in operation, plese view our SuperSleight demo in IE 6 or less.

To call SuperSleight from a script, use the run method of the supersleight object. This method takes the same three optional parameters as the init method.

Download SuperSleight 1.1.0
View SuperSleight Demo

A time for every season . . .

Dec 4 | Posted by Joshua Ingber | 2 comments

… Yet, there is no crying in baseball, and I am not sure there was ever a time in history when it was socially cool, outside of Russia, to play chess. There are other unnatural mysteries that confound me, like why people use Sacajawea coins or why there wasn’t a sequel to Dances With Wolves. Billy Joel’s words ring true, “surviving is a noble fight”.

The upward trend in interracial marriage suggests there is hope for the world. Yes, maybe we will all sit by a pool on a sunny day wearing hyper-color T-shirts, sipping on bubble tea without the bubbles. Until then, we survive. And for those us who are finishing the race, we look back at the two basics which sustained us: hope and good design.

Hope may be dashed in some parts of the world with the ongoing war, the ever growing gap between the rich and the poor, and the writer’s strike, but that is short-lived. For all that hope requires is a flashlight strong enough to beam through the darkness. Then people dream again of pools and bubble tea.

Design is a far more fragile matter. Our sense of quality comes from design. A well designed argument enriches our lives, a well designed hair style can inspire a generation, and a well designed automobile can help attract the opposite sex. Unfortunately, an argument can be shattered with bullets, a hair style can be combed over, and an automobile can be destroyed by a jealous lover. Without design we’d have no sunny days, no pools, no hyper-color shirts, and no bubble tea, as these were all inventions of designers. (Thank you G-d, for the sunny days).

So this holiday season, hug a good designer. Because if design dies, we pin our hopes for survival on hope itself. And I ask you this, what would we hope for?

Search the Archives
Feeds

Upcoming events

  • 24 Jul 2008

O'Reilly user group program member

Add to Technorati Favorites

We endorse

Basecamp

Want to work with us yet? We’re ready when you are.