Currently when using with jQuery >= 1.9, Firebug will capture a JS error message as below:

TypeError: $.browser is undefined

As refer to http://api.jquery.com/jQuery.browser/:

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.

A dirty workaround patch attached to remove the usage of $.browser; As a better alternative, we may consider using http://api.jquery.com/jquery.support/ instead?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hswong3i’s picture

Status: Active » Needs review
FileSize
1.49 KB

Status: Needs review » Needs work

The last submitted patch, 1: l10n_client-browser_is_undefined_jquery_gt_19-2190007-1.patch, failed testing.

hswong3i’s picture

hswong3i’s picture

hswong3i’s picture

Status: Needs work » Needs review

The last submitted patch, 3: l10n_client-browser_is_undefined_jquery_gt_19-2191771-2.patch, failed testing.

axe312’s picture

Status: Needs review » Reviewed & tested by the community

Patch is working :)

fietserwin’s picture

+1 on RTBC for the patch. Tested it in IE(11) and even there it works.

gaetanpru’s picture

Thanks for patch, it's working for me too

Kgaut’s picture

I can confirm too that the patch is working.

+1 for RTBC

XTaz’s picture

Patch working for me too.

Thanks

Nitebreed’s picture

Better than stripping out functionality, we want a substitute for $.browser.

See attached patch

Nitebreed’s picture

Status: Reviewed & tested by the community » Needs review

Status: Needs review » Needs work

The last submitted patch, 12: l10n_client-support_jquery_1_9.patch, failed testing.

fietserwin’s picture

Looking at what is done within the if statements, I really wonder why it was put in an if to start with? Is adding or removing a class browser dependent? I think not\, so it may be the processing done after adding or removing a class, does that throw errors (and thus invalidate all other js on the page) or is just not functioning. In both cases I would have expected some comments. Unfortunately they are not there, so let's just remove the if's.

knalstaaf’s picture

jQuery 1.10 is now the default for jQuery update (and many modules with it). Shouldn't we anticipate on 1.11 (which is already out) or at least 1.10?

rpsu’s picture

Status: Needs work » Needs review
FileSize
971 bytes

IE8 and below seem to work weirdly unexpected ways (based on http://forum.jquery.com/topic/addclass-not-working-in-ie, however I did not test this thoroughly).
Apparently the worst thing that could happen is IE just not adding the given class to DOM. From that perspective these if's can be removed.

This patch does remove those if's in the js-file. Please test this for IE8 and below.

rfay’s picture

Status: Needs review » Reviewed & tested by the community

This solves the (serious) problem for me (Chrome 45.0.2454.93 (64-bit), visiting a google maps API page). Marking RTBC, as it's important to solve this serious problem.

Arne Slabbinck’s picture

Patch #17 fixed following error for me

Uncaught TypeError: Cannot read property 'msie' of undefined

Thx!

yogaf’s picture

Title: "$.browser is undefined" for jQuery >= 1.9 » RTBC "$.browser is undefined" for jQuery >= 1.9

Please commit.
Patch #17 works.
Thank you.

  • SebCorbin committed 980e1dd on 7.x-1.x authored by hswong3i
    Issue #2191771 by hswong3i, Nitebreed, rpsu: RTBC "$.browser is...
SebCorbin’s picture

Status: Reviewed & tested by the community » Fixed

Actually went with #4 as we do not really know why this was set at first, as said #15

Feel free to reopen another issue if issues are encountered with that change.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Brn’s picture

Another method :
- download JQuery Browser plugin https://plugins.jquery.com/browser/
- make your "custom" module
- put the "jquery.browser.js" file in your "custom" module folder
- call this js plugin file by adding code in "custom/custom.module" :

<?php
/**
 * Implementation of hook_init().
 */
function custom_init() {
    $path = drupal_get_path('module', 'custom');
    drupal_add_js($path . '/jquery.browser.js');
}
?>