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.
Thanks,
Karthik
Hi Karthik!Have a look at these two posts:
https://www.outsystems.com/forums/discussion/45558/browser-detection/
https://www.outsystems.com/forums/discussion/18848/how-does-one-determine-the-current-browser-the-user-uses/
Chris Vorster wrote:
Hi Chris, I am using Outsystems 10 and how can i interpret safari browser using the function GetUserAgent() ?
Hi,
If you are using OutSystems UI you can get GetBrowser
https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Built-in_Functions/Environment#GetUserAgent
Regards,
Daniel
Daniël Kuhlmann wrote:
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.
JC
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.
Just got a script from stackoverflow and works for me for React:
// Internet Explorer 6-11var isIE11 = /*@cc_on!@*/false || !!document.documentMode;$parameters.IsIE11 = isIE11;
Hi,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. Regards,
Jordy
HiPlease try below code.
----------------------
$(document).ready(function(){
/* Get browser */
$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
/* Detect Chrome */
if($.browser.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 */
if($.browser.safari){
/* Do something for Safari */
alert("You are using Safari!");
});