PDA

View Full Version : Firefox version sniffing


sneddo
08-14-2008, 08:13 AM
Hay all,

I had a search around the forum and couldn't find any information on this. I then turned to Google and found a way of telling what version of Firefox is being used.

This is what I am using to detect the version:

if(navigator.userAgent.match("rv:1\.9")) {
Ext.isFX3 = true;
Ext.isFX2 = false;
Ext.isFX15 = false;
Ext.isFX3Plus = false;
} else if(navigator.userAgent.match("rv:1\.8\.1")) {
Ext.isFX3 = false;
Ext.isFX2 = true;
Ext.isFX15 = false;
Ext.isFX3Plus = false;
} else if(navigator.userAgent.match("rv:1\.8")) {
Ext.isFX3 = false;
Ext.isFX2 = false;
Ext.isFX15 = true;
Ext.isFX3Plus = false;
} else {
Ext.isFX3 = false;
Ext.isFX2 = false;
Ext.isFX15 = false;
Ext.isFX3Plus = true;
}

Let me know what you think, If you can see any problems with it please let me know, have tested on firefox 2.0.0.1.6 and 3.0.1 and it seems to work well.

Regards

David

NoahK17
08-14-2008, 10:33 AM
Couldn't you just use one variable instead of using boolean values? :)

mystix
08-14-2008, 10:44 AM
plus there's already these 3 flags:
http://extjs.com/docs/?class=Ext&member=isGecko
http://extjs.com/docs/?class=Ext&member=isGecko2
http://extjs.com/docs/?class=Ext&member=isGecko3

sneddo
08-14-2008, 10:47 AM
I guess, but I wanted it to work in that same way as the Ext sniffing.

Unless I'm missing something you need to set them all for this to be available do you not?

cheers,

mystix
08-14-2008, 10:49 AM
they're public properties.
just use them -- Ext sets them for you OOTB.

sneddo
08-14-2008, 10:49 AM
plus there's already these 3 flags:
http://extjs.com/docs/?class=Ext&member=isGecko
http://extjs.com/docs/?class=Ext&member=isGecko2
http://extjs.com/docs/?class=Ext&member=isGecko3

Ahh I guess these must have been added in the new version?

although I have downloaded it I have not yet put it into my app! that would have saved me a few mins.. never mind!

cheers,

mystix
08-14-2008, 10:54 AM
isGecko has been there since Ext 1.0.

isGecko3 was added in 2.2.

i can't remember when isGecko2 was added.

sneddo
08-14-2008, 11:00 AM
isGecko has been there since Ext 1.0.

isGecko3 was added in 2.2.

i can't remember when isGecko2 was added.

You are right isGecko has been there since version 1, but In my case I needed to know what version of FF was being used, and isGecko2 and isGecko3 didnt come in till the new version, else Id have used it :)

Thank you though, knowing that there is a solution already in Ext ill update my version and use the ext stuff, and change where my app uses the stuff I put together.

cheers