I am Ad Taylor

Detecting old versions of Firefox for progressive enhancement

short URL
http://www.iamadtaylor.com/?p=176

Links

Shorts

This is a selection of hints, tips, finds and anything else I want to archive on the interwebs.

Why not just use twitter?

In part because I want to write a little more than 140 characters but mainly as I fear linkrot with much of what I tweet.

Detecting old versions of Firefox for progressive enhancement

Today I have been redesigning my CV (as you do) as I wanted it to be hosted/printed/enjoyed from my site and not as a PDF. Whilst designing it I saw a post by Jonathan Snook on CSS text rotation, this is really exciting as Jonathan also shows you how to use a filter to make it work in IE — exciting stuff.

I decided to use it on my CV, but whilst designing I noticed it wasn’t working in Firefox older than 3.5. This sucked. So I set about BROWSER SNIFFING. I didn’t take this decision lightly but I figured it is no different to [if IE] and the only difference to the code would be removing a class.

jQuery to the rescue

To make long story short, I used the version function in jquery. Comments are in the code:


if($.browser.firefox || $.browser.mozilla) {

 var ver = $.browser.version;

 // Take out al the full stops so we can use it 
 // as an integer
 ver = ver.replace(/\./g,"");

 // As the version numbers differ in length
 // we force all numbers to be the same length.
 // This is ok as we are only interested in the 
 // first couple of digits
 var verl = ver.length;
 while (verl < 7) {ver = ver + '0'; verl = ver.length;}
 ver = parseInt(ver);

 // Check to see if the browser is older that 3.5
 if(ver <= "1910000") {$("h3").removeClass('rotate');}

}