Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get property 'msie' of undefined or null reference

Tags:

jquery

jqgrid

I'm trying to create a JQGrid in my MVC 4 view and getting a

Unable to get property 'msie' of undefined or null reference

error when adding the JQGrid javascript files

bundles.Add(new ScriptBundle("~/Bundles/Shared/JS").Include(
            "~/Scripts/jquery-1.9.1.min.js",
            "~/Scripts/jquery.validate.min.js",
            "~/Scripts/bootstrap.js",
            "~/Content/silviomoreto-bootstrap-select/bootstrap-select.min.js",
            "~/Scripts/js/Shared/Index.js",
            "~/Scripts/js/Shared/Validation.js",
            "~/Scripts/jquery.placeholder.js",
            "~/Content/jquery.jqGrid-4.4.3/js/i18n/grid.locale-en.js",
            "~/Content/jquery.jqGrid-4.4.3/js/jquery.jqGrid.min.js"));

The error occurs on the following line

e=n.browser.msie&&"6.0"==n.browser.version

Any idea why this is happening?

like image 526
Andre Lombaard Avatar asked Oct 14 '13 11:10

Andre Lombaard


2 Answers

From the jQuery docs for jQuery.browser:

This property was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. Please try to use feature detection instead.

So you'll have to drop down to an older version of jQuery or use the migrate plugin.

like image 82
James Allardice Avatar answered Nov 10 '22 16:11

James Allardice


I also had similar problem as this property was removed in jQuery 1.9... Add below code inside your page script tag.

 jQuery.browser = {};
  (function () {
   jQuery.browser.msie = false;
   jQuery.browser.version = 0;
   if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
    jQuery.browser.msie = true;
    jQuery.browser.version = RegExp.$1;
   }
})();
like image 25
Anand Avatar answered Nov 10 '22 18:11

Anand