-1

I am pretty new in JavaScript and JQuery and I have the following problem.

I have included JQuery 2.1.4 and I am tryng to implement a very simple JQuery script that show thw browser name and its version.

So I am trying to follow this official documentation "tutorial": http://api.jquery.com/jquery.browser/

So, into my page, I done something like this:

<script>

    $(document).ready(function() {
        alert($.browser.version);
    });

</script>

But it don't works infact the popup is not shown and into the FireBug console I obtain the following error message:

TypeError: $.browser is undefined
    alert($.browser.version);

Why? What am I missing? How can I fix this issue?

AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
  • possible duplicate of [Browser detection in JQuery 2.0 and higher](http://stackoverflow.com/questions/17115650/browser-detection-in-jquery-2-0-and-higher) – Carsten Massmann Sep 07 '15 at 09:04

1 Answers1

2

The feature of $.browser is deprecated from jQuery v 1.3 and is removed from the jQuery 1.9, so you cannot use it in the jQuery version 2.

From the Docs:

Description: Contains flags for the useragent, read from navigator.userAgent. This property was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. Please try to use feature detection instead.

Tushar
  • 85,780
  • 21
  • 159
  • 179
  • Ok and so using JQuery 2 what can I do to obtain the browser name and the broswer version? – AndreaNobili Sep 07 '15 at 09:04
  • @AndreaNobili Have a look at http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser – Tushar Sep 07 '15 at 09:06