skip to content

Mootools – browser sniffing

I know, I know, browser sniffing is a bad habit and it should not be used, but still, there are cases when you will want to display a message to the user (ordinary users, that don’t hack their’s browser navigator.userAgent) or you really need to know what browser is he using.

For example Chrome. It’ss ok, is using webkit, but it’s not webkit… transparent png, with opacity set lower then 1 will look just awful in  Chrome.

So I wrote a simple function, “stealing” some code from PPK.

Include the script in your pages, and it will give you 2 more variables in Browser. Engine:

Browser.Engine.browserName

Browser.Engine.browserVersion

 

Switch to our mobile site