Frederick Posted May 5, 2021 Share Posted May 5, 2021 I am using the following code to try to get the browser name but all I am getting is "Others". It is the same whether I run in Firefox, Chrome, Edge or Opera. var ClientInfo : TUniClientInfos; begin ClientInfo:=UniApplication.ClientInfo; if ciIE in ClientInfo then Result := 'IE' else if (ciFireFox in ClientInfo) or (ciFirefox2 in ClientInfo) or (ciFirefox3 in ClientInfo) then Result := 'FireFox' else if ciOpera in ClientInfo then Result := 'Opera' else if ciSafari in ClientInfo then Result := 'Safari' else if ciChrome in ClientInfo then Result := 'Chrome' else Result := 'Other'; end; Additionally, how do I detect the Microsoft Edge browser and the version number of any browser? -- Frederick (UniGUI Complete - Professional Edition 1.90.0.1549) Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 5, 2021 Share Posted May 5, 2021 46 minutes ago, Frederick said: Additionally, how do I detect the Microsoft Edge browser and the version number of any browser? Hello, You can improve a little with this function: function getBrowserName(AUserAgent: string): string; function TMainForm.getBrowserName(AUserAgent: string): string; begin if AUserAgent = '' then begin Result := ''; Exit; end; AUserAgent := LowerCase(AUserAgent); if Pos('edge', AUserAgent) > 0 then Result := 'edge' else if Pos('edg', AUserAgent) > 0 then Result := 'chromium based edge (dev or canary)' else if Pos('opr', AUserAgent) > 0 then Result := 'opera' else if Pos('chrome', AUserAgent) > 0 then Result := 'chrome' else if Pos('trident', AUserAgent) > 0 then Result := 'ie' else if Pos('firefox', AUserAgent) > 0 then Result := 'firefox' else if Pos('safari', AUserAgent) > 0 then Result := 'safari' else Result := 'other'; end; Usage: procedure TMainForm.UniFormActivate(Sender: TObject); var C : TUniClientInfoRec; userAgent: string; begin UniLabel7.Caption:=UniApplication.RemoteAddress; C:=UniApplication.ClientInfoRec; UniLabel6.Caption:=C.BrowserType; UniLabel4.Caption:=IntToStr(C.BrowserVersion); UniLabel5.Caption:=C.OSType; UniLabel9.Text := getBrowserName(UniSession.UserAgent); //<----- end; https://social.msdn.microsoft.com/Forums/en-US/edde0150-9478-4ca6-ba0f-9e084b5a4719/how-to-detect-microsoft-edge-chromium-chrome-ie-browser-using-javascript?forum=iewebdevelopment Quote Link to comment Share on other sites More sharing options...
Frederick Posted May 5, 2021 Author Share Posted May 5, 2021 Thanks. The GetBrowserName() function gives me the information I need. However, the BrowserType, OSType and BrowserVersion properties from UniApplication.ClientInfoRec do not return anything of value since the first two are blank strings and the third is a 0 regardless of the browser I run the app with. Quote Link to comment Share on other sites More sharing options...
55143681 Posted May 7, 2021 Share Posted May 7, 2021 On 5/5/2021 at 3:40 PM, Frederick said: Thanks. The GetBrowserName() function gives me the information I need. However, the BrowserType, OSType and BrowserVersion properties from UniApplication.ClientInfoRec do not return anything of value since the first two are blank strings and the third is a 0 regardless of the browser I run the app with. +1 Quote Link to comment Share on other sites More sharing options...
x11 Posted June 24, 2021 Share Posted June 24, 2021 how to get data in mobile? fWebBrowser is 0 (empty) procedure TUniMainModule.GetBrowserType; Var cir: TUniClientInfoRec; begin cir := UniSession.UniApplication.ClientInfoRec; fWebBrowser := cir.BrowserType + ' ' + cir.BrowserVersion.ToString; end; UniSession.UniApplication.ClientInfoRec is empty Quote Link to comment Share on other sites More sharing options...
x11 Posted December 7, 2021 Share Posted December 7, 2021 For mobile Chrome (Android) result is empty Quote Link to comment Share on other sites More sharing options...
alfr Posted December 7, 2021 Share Posted December 7, 2021 Quote Link to comment Share on other sites More sharing options...
x11 Posted December 8, 2021 Share Posted December 8, 2021 ?? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 8, 2021 Share Posted December 8, 2021 On 6/24/2021 at 3:14 PM, x11 said: UniSession.UniApplication.ClientInfoRec is empty 59 minutes ago, x11 said: Please try to use the solution above: Quote Link to comment Share on other sites More sharing options...
x11 Posted December 8, 2021 Share Posted December 8, 2021 9 minutes ago, Sherzod said: Please try to use the solution above: т.е. штатный вариант не предусмотрен для работы с мобильной версией uniGUI? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.