Unable to get property 'msie' of undefined or null reference
Asked Answered
S

4

10

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?

Southeaster answered 14/10, 2013 at 11:55 Comment(0)
S
19

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.

Stipendiary answered 14/10, 2013 at 11:57 Comment(1)
Unfortunately the migrate plugin didn't work and I had to drop down to jquery-1.7.2.min.jsSoutheaster
C
10

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;
   }
})();
Cocksure answered 14/6, 2016 at 8:54 Comment(0)
M
0

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

I guess it should be like this

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

or e === n.browser.msie && "6.0"=== n.browser.version for strict equality

Monteverdi answered 14/10, 2013 at 11:59 Comment(0)
S
0

I had a similar problem with another older script of mine however the majority of users will be running a version of IE over 6.0 so it really was not a big deal for me to give support to 6.0 or below. What I did was just change the line that said

var isIE6 = ($.browser.msie && &.browser.version < 7);

to

var isIE6 = false;
Smyth answered 23/1, 2014 at 1:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.