Joomla: Getting Browser Type and Version Using JBrowser

Joomla provides the JBrowser class that provides convenience methods to extract client browser details from the user agent string.

You first create instance of the Jbrowser object. Pass in the user agent string for JBrowser to parse.


jimport('joomla.environment.browser');
$browser = &JBrowser::getInstance($_SERVER['HTTP_USER_AGENT']);

This will retrieve the name of the browser. Some of the browser types it returns: konqueror (safari), opera, mozilla, msie, palm, blackberry, nokia, iphone etc..


$browserName = $browser->getBrowser();

This will retrieve the version number of browser


$browserVersion = $browser->getMajor();

Some other things you can do with JBrowser


//Returns name of client's operating system
$os = $browser->getPlatform();
//Returns the decimal portion of the version number
$minor = $browser->getMinor();
//checks if browser has certain capability. Returns boolean.
$hasJs = $browser->hasFeature('javascript');

Leave a comment

4 Comments.

  1. Hm, I am comfortable with this however not completely positive, so i’m gonna research a touch more.

  2. I did not just make this stuff up. This is how it works in Joomla 1.5.

    This is all taken from the API doc.

Leave a Reply


[ Ctrl + Enter ]