Back to Top

How to detect browser in Joomla

Browser Detection with Joomla

Nowadays almost all people use the mobile devices to access the internet so now many of the websites you can see in responsive which detect the mobile device and load layout as per that.

Well,sometimes you want to load some PHP code only on mobile devices and there are multiple ways in a Joomla to respond a visitor when mobile device detected like many extensions available for free download that help to create mobile compatible version of a Joomla.

So, Today I am going to explain how to detect mobile device using Joomla libraries rather than using any extensions because of using Joomla we can take advantage of built-in browser detection class of Joomla.

First of all, if you are using any external file then you need to load Joomla framework inside that file

So ,let’s see the code:

Now, first you need to use jimport() to get it into availability of the JBrowser class which is located in Joomla’s class library, in the environment sub package and then use the JBrowser class method in the Joomla framework to detect the browser.

Then you need to get an instance of the browser object

As you can see, it’s very simple.I hope this little tutorial helps you with how to use browser detection built-in library into Joomla.Again if you have any questions just drop me a comment. So that’s all for now.
Thanks for reading and feel free to share your thoughts! Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Comments (4)

  1. why not use this API : http://www.ducis.net/Miri ? It’s much more detailed, accurate, up-to-date and faster. 😉

  2. I am not sure about this API and this is about how we use in built library provided by Joomla.

  3. Hi there,
    I have a joomla website and a webview app of the same.

    I want to disable google adsense ads only on the webview app and the ads should appear if the user access the website using other browsers on mobile or desktop devices.

    Developer of the webview app suggested adding this code
    public static final String WEBVIEW_USER_AGENT =”webview”;

    On this page
    mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java

    And Said

    You will have to modify your Joomla backend and add logic which will disable ads when the user agent is “webview”.

    Can you help me with this

  4. Thank you very much bhoomi ji

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

An Introduction to Kubernetes

Posted on 8 years ago

Bhumi

How to create Cron jobs in WordPress?

Posted on 11 years ago

Bhumi