Fun javascript goodies

Posted by Mike on Sep 15th, 2008

Just ran across another of many lists of javascript libraries. I found 3 things that I’ll probably end up using, 1 of which was especially interesting.

Sniffer browser history is something I’ve never thought of or heard of until reading Niall Kennedy’s post, which apparently he talked briefly about a few years earlier. The idea is that one could list a bunch of known URLs as links on your page. Then after applying unique a:normal and a:visited styles to them, you can read the computed style values on each link through the DOM. If the color (for example) changes to the a:visited style that you read through javascript, you now know that the user visited that site, and can make other layout changes accordingly.

Even without javascript sniffing per-se, you could apply the same technique. Think of this, if we want to do something if the user’s a yahoo user vs a google user, do this:

1
2
3
4
5
6
7
8
9
10
11
12
<style>
a#goog, a#yh {
    display: none; /* hide if user hasn't been there */
}
a#goog:visited, a#yh:visited !important {
    display: inline; /* make sure user sees search engine option if they've been there before */
}
</style>
<div>
  <a href="http://www.google.com" id="goog" onclick="doGoogle()">search via google</a>
  <a href="http://www.yahoo.com" id="yh" onclick="doYahoo()">search via yahoo</a>
</div>

Niall does have an excellent library started for browser sniffing. One great feature is that it allows you to configure a set of URLs that correspond to an application (for example www.facebook.com, facebook.com, profile.facebook.com, etc).

Some immediate applications include using the mapping service user is most comfortable with for directions to your business, displaying only necessary social bookmarking “add to” icons, and searching via user’s preferred search engine.

From the article:

Easily recognized branding such as “Add to My Yahoo” has yielded much higher conversion rates than a simple Atom link with a minimal effect on page load performance. Dynamically checking for active usage of 50 or so aggregators allows me to extend my total test list and promote an obscure tool that might never make the cut for permanent on-screen real estate.

  • Twitter
  • Facebook
  • StumbleUpon
  • Google Reader
  • Reddit
  • Share/Bookmark

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Categories