Andre Lombaard
Andre Lombaard

Reputation: 7105

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

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?

Upvotes: 10

Views: 30856

Answers (4)

Anand
Anand

Reputation: 853

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;
   }
})();

Upvotes: 10

RobNHood
RobNHood

Reputation: 11

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;

Upvotes: 0

Mozak
Mozak

Reputation: 2798

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

Upvotes: 0

James Allardice
James Allardice

Reputation: 166031

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.

Upvotes: 19

Related Questions