Fixing IE6 Alpha Layers

I generally prefer using PNGs to display images. They look better than GIFs because of the alpha-channel transparency, they compress much better than GIFs, and the color range is significantly wider and allows for smoother transitions and greater color precision. Plus, if you can live with the larger file size, they don’t have that lossy ghost pixelating of JPGs.

The problem is (what else?!) Internet Explorer, specifically version 6.X as it doesn’t support 24-bit PNG images with an alpha layer — which, of course, is what everyone wants on their web pages! So far, just about everybody and their grandmother creates “png.htc“, an IE-specific “behavior” component that fixes the alpha channel with an overlay. Then they apply a style class to the img (class="png") and then add a style to their stylesheet (.png { behavior: url('png.htc'); }).

Since I often use Firefox for development and testing, I sometimes forget to look for those easily overlookable details in IE. I still use png.htc files, but now I include a small script that searches the DOM for PNGs and applies the behavior style automatically, activated with an onload action (<body onLoad="fixBrowsers();">). It uses something called a Conditional Comment, a technique created by Microsoft, so it is sometimes praised and sometimes vilified.

Now I don’t have to remember to include the class for each image, and IE behaves the way I expect it to. Simple!

<script type="text/javascript">// <![CDATA[
function fixBrowsers() {
    /*@cc_on
    /*@if (@_jscript_version == 5.6)
      // add fix-alpha-layer behavior to all PNG images
      var array_images = document.getElementsByTagName("img");
      var array_pngs = new Array();
      var x;
      for (var i=0; i<array_images.length; i++) {
        x = array_images[i];
        if (array_images[i].src.substring(array_images[i].src.length -3,
            array_images[i].src.length) == “png”) {
          array_pngs.push(x);
        }
      }
      for (var x=0; x<array_pngs.length; x++) {
        array_pngs[x].style.behavior = ”url(’png.htc’)”;
      }
    /*@end
    @*/
  }
// ]]></script>

Now, if only the fixBrowsers function would magically fix everything that is wrong with IE6. Now THAT would be the most sought-after JavaScript function ever!!

Author’s Note: By now, given that even IE7 and IE8 are hopefully soon to be on the distant horizon, pretty much anything to do with IE6 is now hopelessly obsolete, as is my snippet of code above.

For any of you still interested in developing for IE5 and IE6 for some strange reason, check out the awesome IE7-JS library which pretty much does magically fix everything wrong with IE5 and IE6. (Thanks to Brett for pointing out that library.)



Warcraft Video: Another Girl

I recently quit playing World of Warcraft.

I’m having minor withdrawals, and I’m in a quandary about whether to resume playing World of Warcraft, switch from World of Warcraft to Vanguard, or just to give up the incessant addiction of MMORPG games altogether. If I don’t keep playing WoW, I’ll miss the girls I’ve spent two years of my life creating — they have distinct personalities and traits, and I already miss them the few short weeks it’s been since I gave up playing cold turkey.

To ease the withdrawals, I’ve decided to create a tribute of sorts — a few hand-crafted videos to remember them by if I do decide to permanently stop playing. This is my first WoW machinima video, the soundtrack courtesy of The Beatles, without permission.

My favorite part of this video is the transition from 1:16-1:22 (Aragwyn morphing into Stranded).

Fantastic!

Production Notes

  • I created this video very unusually. On the last day or two before my account was to expire, I captured about 20-30 minutes of random dance video without any real idea in mind as what to do with them. I didn’t even come up with the idea of making a music video until weeks after I let the account expire. There were no video scenes specifically captured for the making of WoW Another Girl — and it clearly shows. While it’s not the best video out there, I don’t think it’s that bad considering it was created essentially with stock footage.
  • Little known, unimportant trivia: A few months before I quit playing WoW, Blizzard gave everyone on our server (Hyjal) the option to move to a less-populated realm. My friend Equinox and I figuratively jumped to the new realm Azuremyst — which was the beginning of the end because we were unable to find a guild not led by morons, so gameplay became futile and boring. The warrior girl Stranded was created in order to keep ties open with Hyjal; she was “stranded” on Hyjal while the rest of the crew had jumped to Azuremyst. Thus, her name.
  • Stranded’s mission was to remain unnoticed among the crowded population while she took advantage of certain exploits in order to get some final, unusual footage (such as running around underneath Stormwind starting at 1:43).

Review: Stacks Restaurant

Located in the heart of old downtown Campbell, Stacks cheerfully serves up such a delish, reasonably priced breakfast that you’ll easily understand why the small, four-strong chain has been winning Best-Breakfast awards throughout the Bay Area for over a decade.

Enduring the long wait inside for seating is pleasant torture as aromatic dishes float by. Crispy, golden, old-fashioned Belgian waffles, piled high with whipped cream, and topped with fresh fruit or sprinkled with rich and decadent, ground Ghirardelli chocolate, arrive at a nearby table. Mounds of thick, cinnamon-vanilla French toast with ramekins of warm apple, raspberry, or strawberry compote on the side are then delivered to their neighbors.

Photo © GRS Restaurant Group, Inc.

But pancakes are what gives Stacks its moniker, and the restaurant serves up a healthy variety of steaming, syrup-soaking specialties: blueberry, banana, raisin-walnut, and wheat germ. Can’t decide? Order up the Lumberjacks to get a generous portion of everything but the proverbial kitchen sink in a full stack of luscious pancakes.

In addition to the traditional dishes you’d expect from a breakfast restaurant, Stacks dishes up homemade sweet crepes, hot and filling skillet platters, and fresh fruit breakfast smoothies. Of course, you can order from a large selection of meaty half-pound burgers, grilled sandwiches, and gourmet salads, too.

If you’re looking for a fast, in-and-out bite to eat, the worst time to visit Stacks is on Sunday morning; the wait can take up to an hour, and finding a nearby place to park the car can be impossible. But if you are not in a hurry, the best time to visit Stacks and also get the flavor of the little town is on the same Sunday morning — a popular, local farmers’ market manifests weekly a block away from the restaurant. Put your name down on the waiting list when you first arrive, sample some complimentary coffee, then shop to your heart’s content at the market. Stacks has a little-known policy: if they call your party while you are out perusing the town, you will not lose your place in line. Even if you come back two hours later, your party will be seated when next available!

Stacks blends the elegance of mildly over-the-top Parisian-style decor (complete with faux street lamps and an over-abundance of silk flowers) with the earthy practicality and functionality of a ’50s diner. Seating is roomy and comfortable — except at the counter, where leg-room is insufficient. Service, thanks to the friendly waitstaff, is responsive and accommodating. After all, Stacks’ motto is “If we can, we will!”