Member Sign In
Not a member?

A Wired.com user account lets you create, edit and comment on Webmonkey articles. You will also be able to contribute to the Wired How-To Wiki and comment on news stories at Wired.com.


It's fast and free.

Sign in with OpenID
Sign In
Webmonkey is a property of Wired Digital.
processing...
Join Webmonkey

Please send me occasional e-mail updates about new features and special offers from Wired/Webmonkey.
Yes No

Please send occasional e-mail offers from Wired/Webmonkey affiliated web sites and publications, and carefully selected companies.
Yes No

I understand and agree that registration on or use of this site constitutes agreement to Webmonkey's User Agreement and Privacy Policy.
Webmonkey is a property of Wired Digital.
processing...

Retrieve Sign In

Please enter your e-mail address or username below. Your username and password will be sent to the e-mail address you provided us.

or
Webmonkey is a property of Wired Digital.
processing...

Welcome to Webmonkey

A private profile page has been created for you.
As a member of Webmonkey, you can now:
  • edit articles
  • add to the code library
  • design and write a tutorial
  • comment on any Webmonkey article
Close
Webmonkey is a property of Wired Digital.

Sign In Information Sent

An e-mail has been sent to the e-mail address registered in this account.
If you cannot find it in your in-box, please check your bulk or junk folders.
Sign In
Webmonkey is a property of Wired Digital.

Solving Internet Explorer’s PNG Shortcomings with JavaScript

ie7.jpgMost modern browsers, like Firefox, Safari and Opera, offer support for PNG images with full alpha channel transparency. Even Internet Explorer 7 has gotten in on the PNG transparency act, which means designers can take advantage of sophisticated things like gradients or faded images.

But there’s one problem. The same problem web designers always face: Internet Explorer 6. Yes the old beast is archaic, but sadly, widely used and your transparent PNGs won’t work. There are some hacks out there to make IE6 use an alternate image, but most of them are quite cumbersome and difficult to deploy and reuse.

Which is why Drew McLellan of 24 Ways decided it was time for new solution. McLellan has just released an updated JavaScript package, known as Supersleight, for selectively applying CSS filter rules to IE6 only so IE6 will display an alternate gif image.

SuperSleight is based on Aaron Boodman’s script Sleight, which deals with PNG images in the page, but SuperSleight adds the ability to handle images loaded from CSS as well.

McLellan’s new version of SuperSleight script adds a number of new and useful features:

  • 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.

Using SuperSleight is dead simple, just link to the JavaScript file using conditional comments so that it is delivered to only Internet Explorer 6 or older.

[via Simon Willison]

Post Comment Comments Permalink Print
Reddit Digg

 
Subscribe now

Special Offer For Webmonkey Users

WIRED magazine:
The first word on how technology is changing our world.

Subscribe for just $10 a year