Pregunta

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);
¿Fue útil?

Solución

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.

Otros consejos

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
}

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]-->

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

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

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

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;

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top