I'm sorry if this question has been asked already. How would I find a user's browser and version using JavaScript or jQuery? I know that .browser()
is deprecated as of jQuery 1.9. I am not doing this for code specific purposes, I'm trying to find the browser type for statistical purposes.
Asked
Active
Viewed 202 times
0

David Thomas
- 249,100
- 51
- 377
- 410
-
1You can read `navigator.userAgent`, but it’s generally better to check the `User-Agent` header on the server side. – Ry- Jun 04 '14 at 01:32
-
Check here http://stackoverflow.com/questions/14892095/browser-msie-error-after-update-to-jquery-1-9-1 – elclanrs Jun 04 '14 at 01:35
-
This is a fairly easy topic to google ;) http://stackoverflow.com/questions/6505027/best-way-to-find-browser-type-version – Felk Jun 04 '14 at 01:35
-
@elclanrs: That only checks for Internet Explorer. – Ry- Jun 04 '14 at 01:35
-
@Felk, I've been googling it for about an hour and found nothing helpful. – Jun 04 '14 at 01:40
2 Answers
1
Yes is it depecated already in jquery 1.9.
I guess the best code for determining the browser is to usethe traditional
navigator.userAgent

HandsomeG
- 113
- 9
-
http://www.w3fools.com/ | https://developer.mozilla.org/en-US/docs/Web/API/NavigatorID.userAgent – Ry- Jun 04 '14 at 01:36
-
Note that User Agent is not guaranteed to be correct. Should be fine for statistical purposes though – Felk Jun 04 '14 at 01:36
-
But he is going to use this for "Statistical purposes" right? also, by using this code, you don't have to check for compatibility of your jquery because this is recognized by most browsers. – HandsomeG Jun 04 '14 at 01:38
-
-
Then the code above is the best solution for you aim. Please mark this answer if you find this suits your requirement. Thanks! – HandsomeG Jun 04 '14 at 01:46
-1
There is a JS Plugin thst you can use:
<p>
Click to <a id="detect_browser"
href="javascript:void(0);">Detect browser properties</a>
</p>
$("#detect_browser").click(function() {
alert(JSON.stringify(bowser, null, ' '));
});

almo
- 6,107
- 6
- 43
- 86
-
1And don't use `javascript:` in `href`s, it's unnecessary and obtrusive. (Trying not to make a Mario joke...) – David Thomas Jun 04 '14 at 01:37