Questions tagged [browser-detection]

Detecting the type and version of the browser the user uses to view the webpage.

Detecting the type and version of the browser the user uses to view the webpage. Most of the time the decision is based on the User-agent string or the existence of some proprietary properties.

In most cases, it is considered bad practice. Feature detection is to be used instead.

520 questions
1943
votes
64 answers

How to detect a mobile device using jQuery

Is there a way to detect whether or not a user is using a mobile device in jQuery? Something similar to the CSS @media attribute? I would like to run a different script if the browser is on a handheld device. The jQuery $.browser function is not…
superUntitled
  • 22,351
  • 30
  • 83
  • 110
1275
votes
46 answers

Detecting a mobile browser

I'm looking for a function that returns a boolean value if the user is using a mobile browser or not. I know that I can use navigator.userAgent and write that function by using regex, but user-agents are too various for different platforms. I doubt…
ave
  • 18,083
  • 9
  • 30
  • 39
1068
votes
30 answers

How to detect Safari, Chrome, IE, Firefox and Opera browsers?

I have 5 addons/extensions for Firefox, Chrome, Internet Explorer(IE), Opera, and Safari. How can I correctly recognize the user browser and redirect (once an install button has been clicked) to download the corresponding addon?
FrankC
  • 11,113
  • 4
  • 16
  • 21
718
votes
14 answers

Targeting only Firefox with CSS

Using conditional comments it is easy to target Internet Explorer with browser-specific CSS rules: Sometimes it is the Gecko engine (Firefox) that misbehaves. What would be best…
avdgaag
  • 41,292
  • 7
  • 29
  • 26
488
votes
33 answers

Check if user is using IE

I am calling a function like the one below by click on divs with a certain class. Is there a way I can check when starting the function if a user is using Internet Explorer and abort / cancel it if they are using other browsers so that it only runs…
user2571510
  • 11,167
  • 39
  • 92
  • 138
342
votes
34 answers

How can you detect the version of a browser?

I've been searching around for code that would let me detect if the user visiting the website has Firefox 3 or 4. All I have found is code to detect the type of browser but not the version. How can I detect the version of a browser like this?
odle
  • 5,172
  • 8
  • 29
  • 33
270
votes
19 answers

JavaScript: How to find out if the user browser is Chrome?

I need some function returning a boolean value to check if the browser is Chrome. How do I create such functionality?
Rella
  • 65,003
  • 109
  • 363
  • 636
267
votes
11 answers

Detecting iOS / Android Operating system

I've done some research, and this question has come up, but not in the way I intend. I'm building a page for a client that is a QR code landing, which is a place to download an application. So he doesn't have to print out 2 QR codes on a page, I'd…
Alexander Lozada
  • 4,019
  • 3
  • 19
  • 41
253
votes
37 answers

Detect IE version (prior to v9) in JavaScript

I want to bounce users of our web site to an error page if they're using a version of Internet Explorer prior to v9. It's just not worth our time and money to support IE pre-v9. Users of all other non-IE browsers are fine and shouldn't be bounced.…
Chad Decker
  • 5,997
  • 8
  • 27
  • 31
251
votes
23 answers

Detect Safari browser

How to detect Safari browser using JavaScript? I have tried code below and it detects not only Safari but also Chrome browser. function IsSafari() { var is_safari = navigator.userAgent.toLowerCase().indexOf('safari/') > -1; return…
Tomas
  • 17,551
  • 43
  • 152
  • 257
233
votes
25 answers

Browser detection in JavaScript?

How do I determine the exact browser and version using JavaScript?
Probocop
  • 10,346
  • 28
  • 85
  • 115
217
votes
16 answers

How to detect IE11?

When I want to detect IE I use this code: function getInternetExplorerVersion() { var rv = -1; if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE…
174
votes
16 answers

Detect Browser Language in PHP

I use the following PHP script as index for my website. This script should include a specific page depending on the browser's language (automatically detected). This script does not work well with all browsers, so it always includes index_en.php for…
GibboK
  • 71,848
  • 143
  • 435
  • 658
167
votes
4 answers

Detect iPad users using jQuery?

Is there a way to detect if the current user is using an iPad using jQuery/JavaScript?
Milandstadt
124
votes
14 answers

Detect Safari using jQuery

Though both are Webkit based browsers, Safari urlencodes quotation marks in the URL while Chrome does not. Therefore I need to distinguish between these two in JS. jQuery's browser detection docs mark "safari" as deprecated. Is there a better method…
AndreKR
  • 32,613
  • 18
  • 106
  • 168
1
2 3
34 35