blink tag compatibility script

Tuesday April 01, 2008 @ 10:38 AM (PDT)

Update: Yeah, April Fools. For the sake of my own sanity, I’ve removed the actual blink tags from the post now that the fun has worn off. Please don’t actually use this code or I’ll hunt you down and throw angry kittens at your face.

While working on a new feature for Yahoo! Search today, I ran across an interesting problem. It seems that some A-grade browsers have a serious bug: they don’t support the HTML <blink> tag, which has been part of a w3c spec since 1999.

Since I absolutely wouldn’t have been able to implement this awesome new feature without the <blink> tag, I went ahead and wrote a JavaScript compatibility shim to add support for it to buggy browsers:

/**
 * blinktag.js v1.0.0 (2008-04-01)
 *
 * Compatibility shim to implement the <blink> element in browsers that don't
 * properly support the w3c spec (for spec details, see
 * http://www.w3.org/Style/HTML40-plus-blink.dtd).
 *
 * For a demo and usage examples, see
 * http://wonko.com/post/blink_tag_compatibility_script
 *
 * Copyright (c) 2008 by Ryan Grove <ryan@wonko.com>.
 * All rights reserved.
 */

setInterval(function () {
    var i, s, tags = document.getElementsByTagName('blink');

    for (i = 0; i < tags.length; ++i) {
        s = tags[i].style;
        s.visibility = s.visibility == 'hidden' ? 'visible' : 'hidden';
    }
}, 1000);

Feel free to use this script in your own projects until Microsoft and Apple fix this bug.

Comments

I wrote an example for YUI’s DualSlider that uses blink (albeit via the css text-decoration property). I’m totally going to update it to incorporate this!

Thanks for filling in where the browser vendors FAIL!

Something that will get our attention. The ADHD community thanks you!

Wow

My first thought was “that’s so unobtrusive, I love it” and my second was “is there a way to avoid scanning the document every time?”

Well done April Fools! (I’d be scared of people went and actually implemented this. Angry kittens won’t suffice.)

I was hoping the inefficient document scan would spark discussion and criticism and encourage people to make fools of themselves. ;)

Copyright © 2002-2012 Ryan Grove. All rights reserved.
Powered by Thoth.