10

I get an error with impromptu ver 4.1 when running under the latest jquery 1.9

Uncaught TypeError: Cannot read property 'msie' of undefined

This was not the case with previous versions of jquery.

The offending line in impromptu is line 20:

var ie6 = ($.browser.msie && $.browser.version < 7);
Upland
  • 691
  • 3
  • 8
  • 18

7 Answers7

24

You could patch Impromptu replacing this line :

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

... by this one :

var ie6 = ( navigator.userAgent.match(/msie/i) && navigator.userAgent.match(/6/) );

... so now it can work with jQuery v1.9.0+. Optionally, you could rollback to jQuery v1.8.3

EDIT (March 12th, 2013)

Thanks @johntrepreneur for your comments, you are correct. Two notes:

  1. This edited line :

    var ie6 = ( navigator.userAgent.match(/msie/i) && navigator.userAgent.match(/6/) );
    

    ... should be replaced by this one :

    var ie6 = ( navigator.userAgent.match(/msie [6]/i) );
    

    ... my bad, I rushed writing the patch. That should do the trick.

  2. Impromptu has completely removed IE6 support in their last commit (on March 25/2013 after this original post). The issue brought by the OP was that Impromptu did break with jQuery v1.9+ ... updating the Impromptu js file to the last version does also fix the issue.

Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
JFK
  • 40,963
  • 31
  • 133
  • 306
  • @undefined : I guess all related instances need to be patched as a workaround. – JFK Jan 24 '13 at 23:51
  • Yes, actually it only checks IE6. +1 – Ram Jan 24 '13 at 23:52
  • 1
    @JFK your replacement line is not the same and incorrectly matches since it's finding any "6" in the userAgent string. I tested it in IE8 and your check matches (when it shouldn't) since the userAgent string has "msie" in it and a "6" somewhere else in it too: "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)". – johntrepreneur Mar 12 '13 at 19:17
  • But what does it return? true/false? – SteveCav Jul 23 '13 at 02:09
  • @SteveCav : If you are using IE6 the var `ie6` returns `true` otherwise `false` – JFK Jul 23 '13 at 02:23
6

I prefer this one to target a range, will run code only on < IE9 & jQuery 1.9+

if (/msie [1-8]./.test(navigator.userAgent.toLowerCase()))
{
    //code here
}
Shazbot
  • 61
  • 3
2

Ever since Jquery deprecated the $.browser funcionality the easiest way that i found, was to create a global in javascript

var LTE_IE9 = false;

and the in use the condition HTML IE selectors

<!--[if lte IE 9]>
<script>LTE_IE9 = true;</script>
<![endif]-->
Kup
  • 882
  • 14
  • 31
0

i use it.

  var browser = $.browser;
    if ( ! browser ) {
       var ua = navigator.userAgent.toLowerCase();
       var m = /(msie) ([\w.]+)/.exec( ua ) || ! /compatible/.test(ua) && /(mozilla)/.exec( ua ) || [];
       browser = { version: m[2] };
       browser[ m[1] ] = true;
    }
0

add Jquery migrate plugin

//cdnjs.cloudflare.com/ajax/libs/jquery-migrate/1.2.1/jquery-migrate.min.js

$.browser.msie removed from > jquery 1.9.X

Saurabh Chandra Patel
  • 12,712
  • 6
  • 88
  • 78
0

As said here, $.browser does not exist anymore in jQuery, since version 1.9.

So check browser.msie error after update to jQuery 1.9.1

Community
  • 1
  • 1
Laurent.B
  • 213
  • 2
  • 14
0

as $.browse is deprecated since jQuery V. 1.4 and removed in after jQuery V. 1.9

still you can fix this problem by these line of code(for all browser)

jQuery.browser = {};
jQuery.browser.mozilla = /mozilla/.test(navigator.userAgent.toLowerCase()) && !/webkit/.test(navigator.userAgent.toLowerCase());
jQuery.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase());
jQuery.browser.opera = /opera/.test(navigator.userAgent.toLowerCase());
jQuery.browser.msie = /msie/.test(navigator.userAgent.toLowerCase());

Works fine for me;

Neel Shah
  • 791
  • 1
  • 6
  • 17