How to detect client browser

Hi All,

Which is the most preferable way to detect client browsers ? I tried GetUserAgent() function and the result returned by the function is "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36". I got the above output for Chrome browser.



Chris Vorster wrote:

Hi Karthik!
Have a look at these two posts:

Hi Chris, I am using Outsystems 10 and how can i interpret safari browser using the function GetUserAgent() ?

Hi Karthik!

I have never used the GetUserAgent() function before (because the output is kinda weird to interpret - seems like it shows compatibility rather than current browser), so I would actually suggest using the GetBrowser action from OutsystemsUIWeb. The result is straightforward.

Daniël Kuhlmann wrote:


If you are using OutSystems UI you can get GetBrowser



Looked at several post regarding the topic and it suggests this approach. However, this only returns a blank text ("") to me. I am running a React application and I tried it on OnInitialize and OnReady to no avail.



Just got a script from stackoverflow and works for me for React:

// Internet Explorer 6-11
var isIE11 = /*@cc_on!@*/false || !!document.documentMode;

$parameters.IsIE11 = isIE11;


The OutSystemsUI GetBrowser client action works (for Reactive), but with a small adjustment. Input should be ToLower(GetUserAgent()) since this action checks a UserAgent text like
for example "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36" if the word 'chrome' in lowercase is present. I've noted this to OutSystems so hopefully they will fix this.




Please try below code.



    /* Get browser */

    $ = /chrome/.test(navigator.userAgent.toLowerCase());

    /* Detect Chrome */


        /* Do something for Chrome at this point */

        alert("You are using Chrome!");


        /* Finally, if it is Chrome then jQuery thinks it's 

           Safari so we have to tell it isn't */

        $.browser.safari = false;


    /* Detect Safari */


        /* Do something for Safari */

        alert("You are using Safari!");