Tips & Tricks

How to detect browser using MooTools 1.3 javascript?

Browser Object is very useful, with this you not only can get information about you browser type and version but you can also get the users’ OS and plugin installed in browser. So let me show how can we get Browser features using Browser Object!

Before some days MooTools have released their next version which is 1.3. This MooTools version comes with a lots of new features and fixes which are in earlier version. One of them is the Browser Object. The Browser Object is very useful, with this you not only can get information about you browser type and version but you can also get the users’ OS and plugin installed in browser. So let me show how can we get Browser features using Browser Object!

Check for the Browser and its version

[cc lang=”javascript”]
// Check for the safari browser
if(Browser.safari) { }

// Check for the IE by name
if(Browser.name == ‘ie’) { }

// Check for the browser with version
if(Browser.name == ‘ie’ && Browser.version == 7) { }
[/cc]

Check for the Plugin

[cc lang=”javascript”]// Check for the flash and version
if(Browser.Plugins.Flash && Browser.Plugins.Flash.version > 9) { }[/cc]

Checking for OS

[cc lang=”javascript”]// Check for windows by name
if(Browser.Platform.name == ‘win’) { }

// Check for mac by property
if(Browser.Platform.mac) { }[/cc]

Checking for Browser features

[cc lang=”javascript”]
// Check for AJAX availability
if(Browser.Features.xhr) { }

// Check for Adobe AIR
if(Browser.Features.air) { }
[/cc]


The Browser Object is a great utility for the websites which are based on browser version or features. What you think about this share with the comments here.

Shares:

Leave a Reply

Your email address will not be published. Required fields are marked *