Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery.browser: Javascript Uncaught TypeError

I'm experiencing an error which wont let my page load.

Uncaught TypeError: Cannot read property 'msie' of undefined

The error in the console refer to this code:

if (jQuery.browser.msie)
    extra_px += 3;
                                                   // Fix Link Clicking on IE 7 and below versions
if (jQuery.browser.msie && Number($.browser.version) < 8) {
    span_text.css('cursor', 'pointer');
    span_text.click(function() {
        window.location = menu_item.parent().attr("href");
    });
}

The weird thing is that it suddenly happened, I didn't change a thing. For reference, I'm using Wordpress.

like image 932
TonalDev Avatar asked Jan 15 '13 12:01

TonalDev


People also ask

What happened to $browser in jQuery?

The $.browser property is deprecated in jQuery 1.3, and its functionality may be moved to a team-supported plugin in a future release of jQuery. Because $.browser uses navigator.userAgent to determine the platform, it is vulnerable to spoofing by the user or misrepresentation by the browser itself.

What is undefined error in JavaScript?

Out of the six primitive types defined in JavaScript, namely boolean, string, symbol, number, Null, and undefined, no other type throws as many errors as Undefined. The error most often than not is faced when the scripts come across uninitialized variable or object. ‘Undefined’ is the property of the global object.

What is the $browser API in jQuery?

Note: This API has been removed in jQuery 1.9; please rely on feature detection instead. The $.browser property provides information about the web browser that is accessing the page, as reported by the browser itself.

What is the most common error in JavaScript?

Out of the six primitive types defined in JavaScript, namely boolean, string, symbol, number, Null, and undefined, no other type throws as many errors as Undefined. The error most often than not is faced when the scripts come across uninitialized variable or object.


2 Answers

jQuery.browser was deprecated in version 1.3, and finally removed in 1.9.

source

As you can see in current version of jQuery, there is no $.browser property anymore.

Most probably it was moved to plugin as was stated in docs.

So if you use the very last version of jQuery, the undefined error is understandable.

like image 97
VisioN Avatar answered Oct 02 '22 06:10

VisioN


Yes, jQuery.browser was deprecated in older version and removed in 1.9.So Now In old version if code written like this

isIE6 = jQuery.browser.msie && jQuery.browser.version < 7 && !window.XMLHttpRequest,

will be replaced it by

isIE6 = navigator.userAgent.match(/msie [6]/i) && !window.XMLHttpRequest,

Cheers!!!

like image 32
Manish Shrivastava Avatar answered Oct 02 '22 05:10

Manish Shrivastava