Can we create a thorough question/answers post with the core methods that allow browser detection in Joomla 2.5 and 3 ? After a quick research in the web, I feel that there is not sufficient information on a single page the fulfills the topic.


A more thorough walk through should really be added to the docs wiki IMO, but sharing what I can via mobile now.

For 2.5 and 3.x compatibility, you can use JBrowser to do some browser detection. However, this class may not work well with newer browsers or versions. To use it to get the browser:

$browser = JBrowser::getInstance()->getBrowser();

For 3.2 and newer, you can use JApplicationWebClient, which is a newer class designed to be more flexible with today's browser options. To use it to get the browser:

$client = JFactory::getApplication()->client->browser;

Both classes are documented on the API site, http://api.joomla.org/cms-3/index.html will link you to the base page for 3.3 docs.

  • 3
    I would not use JBrowser, especially if you want to check if the device is mobile or not or what kind. It's really buggy. May 7 '14 at 7:25

In addition to Michael's answer, the JApplicationWebClient Class has a few other useful properties:

$client = JFactory::getApplication()->client;

// The detected browser used by the web client (returns an integer)

// The detected browser version used by the web client. (string)

// True if the web client is a mobile device (Boolean)

// The detected platform on which the web client runs (integer)

//The web client's user agent string. (string)

// True if the web client is a robot (Boolean)

JApplicationWebClient Class API Documentation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.