javascriptjqueryhtmljquery-2.0

Why I can't show the browser version using JQuery 2?


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?


Solution

  • 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.