How do you detect between a Desktop and Mobile Chrome User Agent?

The problem is the user agent will always have “Chrome” whether it is the desktop or mobile version. So you have to check the more specific case first. $(document).ready(function(){ var ua = navigator.userAgent; if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(ua)) $(‘a.mobile-other’).show(); else if(/Chrome/i.test(ua)) $(‘a.chrome’).show(); else $(‘a.desktop-other’).show(); });

Detecting IE using jQuery

The jQuery documentation for jQuery.browser shows the following warning. (Emphasis is mine.) Because $.browser uses navigator.userAgent to determine the platform, it is vulnerable to spoofing by the user or misrepresentation by the browser itself. It is always best to avoid browser-specific code entirely where possible. Instead of relying on $.browser it’s better to use libraries … Read more

How to target Edge browser with javascript

Try to detect features instead of a specific browser. It’s more future-proof. Only rarely should you use browser detection. With that out of the way: one option is to use a library (there are many intricacies to User Agent strings), or alternatively to parse window.navigator.userAgent manually. Using a parser library # https://github.com/faisalman/ua-parser-js. var parser = … Read more

How to detect IE 11 with javascript in Asp.net

You can explicitly detect IE11 with the following check (using feature detection): if (Object.hasOwnProperty.call(window, “ActiveXObject”) && !window.ActiveXObject) { // is IE11 } Explanation: All versions of IE (except really old ones) have window.ActiveXObject property present. IE11, however hides this property from DOM and that property is now undefined. But the property itself is present within … Read more

Browser detection

if (Request.Browser.Type.Contains(“Firefox”)) // replace with your check { … } else if (Request.Browser.Type.ToUpper().Contains(“IE”)) // replace with your check { if (Request.Browser.MajorVersion < 7) { DoSomething(); } … } else { }

reliable user browser detection with php

Check this code , I’ve found this is useful. Don’t check Mozilla because most browser use this as user agent string if(strpos($_SERVER[‘HTTP_USER_AGENT’], ‘MSIE’) !== FALSE) echo ‘Internet explorer’; elseif(strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Trident’) !== FALSE) //For Supporting IE 11 echo ‘Internet explorer’; elseif(strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Firefox’) !== FALSE) echo ‘Mozilla Firefox’; elseif(strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Chrome’) !== FALSE) echo ‘Google Chrome’; elseif(strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Opera … Read more

How to detect a mobile device using jQuery

Editor’s note: user agent detection is not a recommended technique for modern web apps. See the comments below this answer for confirmation of this fact. It is suggested to use one of the other answers using feature detection and/or media queries. Instead of using jQuery you can use simple JavaScript to detect it: if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera … Read more