Detect Firefox < 3.6

2.6k views Asked by At

I tried to find any good solution to detect firefox versions < 3.6 in order to deliver a notice to them that my website works much better in newer browsers (at least 3.6). I stubled across http://api.jquery.com/jQuery.browser/ - but found no example how to detect all Versions lower than 3.6. Any advice?

Thank you!

4

There are 4 answers

0
Aamir Afridi On BEST ANSWER
/* ===== Firefox ===== */

// Select Firefox
if (jQuery.browser.mozilla) {
    // do sth.
}

// Select Firefox 1.5.x to 2.x
if (jQuery.browser.mozilla && jQuery.browser.version.substr(0, 3) == '1.8') {
    // do sth.
}

// Select Firefox under 3.x
if (jQuery.browser.mozilla && jQuery.browser.version < '1.9') {
    // do sth.
}

// Select Firefox 3.0.x and above
if (jQuery.browser.mozilla && jQuery.browser.version.substr(0, 3) == '1.9') {
    // do sth.
}

// Select just Firefox 2.0.x
if (jQuery.browser.mozilla && jQuery.browser.version == '1.8.1') {
    // do sth.
}

// Select just Firefox 3.0.x
if (jQuery.browser.mozilla && jQuery.browser.version == '1.9') {
    // do sth.
}

// Select just Firefox 3.5.x
if (jQuery.browser.mozilla && jQuery.browser.version == '1.9.1') {
    // do sth.
}

// Select just Firefox 3.6.x
if (jQuery.browser.mozilla && jQuery.browser.version == '1.9.2') {
    // do sth.
}

/* ===== Internet Explorer ===== */

// Select Internet Explorer
if (jQuery.browser.msie) {
    // do sth.
}

// Select Internet Explorer above 6
if (jQuery.browser.msie && jQuery.browser.version > 6) {
    // do sth.
}

// Select Internet Explorer 7 and below
if (jQuery.browser.msie && jQuery.browser.version <= 7) {
    // do sth.
}

// Select just Internet Explorer 6
if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
    // do sth.
}

// Select just Internet Explorer 7
if (jQuery.browser.msie && jQuery.browser.version == '7.0') {
    // do sth.
}

// Select just Internet Explorer 8
if (jQuery.browser.msie && jQuery.browser.version == '8.0') {
    // do sth.
}

// Select just Internet Explorer 9
if (jQuery.browser.msie && jQuery.browser.version == '9.0') {
    // do sth.
}

/* ===== Safari / Chrome ===== */

// Select Safari / Chrome
if (jQuery.browser.safari) {
    // do sth.
}

// Select Safari 3
if (jQuery.browser.safari && (navigator.appVersion.indexOf('3.') != -1)) {
    // do sth.
}

// Select Safari 4
if (jQuery.browser.safari && (navigator.appVersion.indexOf('4.') != -1)) {
    // do sth.
}

// Select Chrome 1
if (jQuery.browser.safari && (navigator.appVersion.indexOf('1.') != -1)) {
    // do sth.
}

// Select Chrome 3
if (jQuery.browser.safari && (navigator.appVersion.indexOf('3.') != -1)) {
    // do sth.
}

/* ===== Opera ===== */

// Select Opera
if (jQuery.browser.opera) {
    // do sth.
}

// Select Opera 9.5 and above
if (jQuery.browser.opera && jQuery.browser.version >= '9.5') {
    // do sth.
}

// Select just Opera 9.5
if (jQuery.browser.opera && jQuery.browser.version == '9.5') {
    // do sth.
}

// Select just Opera 10
// Note: Opera 10's user agent looks like Opera/9.80 [...] Version/10.00
if (jQuery.browser.opera && jQuery.browser.version == '9.8') {
    // do sth.
}
0
karim79 On
var ua = $.browser;
if (ua.mozilla && parseFloat(ua.version.slice(0,3)) < 3.6) {
    alert( "Do stuff for firefox 3.6 or less" );
}
4
Zachary K On

In general you are better off detecting features not versions. Detect whichever features you need and not the version number

1
Amar Palsapure On

Try this

var itsOldFF = false;
var itsFF = false;
$.each($.browser, function (i, val) {
   if (i == "mozilla" && itsFF == false){
      itsFF = true;
      return;
   }
   if(itsFF && parseFloat(val) < 3.6) itsOldFF = true;
}); 
return itsOldFF;

EDIT

Demo on jsFiddle.net