browser.msie error after update to jQuery 1.9.1

2019-01-05 00:22发布

I use the following snip of a script:

if ($.browser.msie && $.browser.version < 9) {
   extra = "?" + Math.floor(Math.random() * 3000);
}

It works fine with jQuery 1.8.3.

Now I updated jQuery to the new version 1.9.1 to use a new script.
Now I get the following error:

TypeError: Cannot read property 'msie' of undefined

I read the change log of the new jQuery version, but nothing should have changed
with msie

Any known bugs, tips or proposals?

11条回答
来,给爷笑一个
2楼-- · 2019-01-05 01:02

Include jQuery migration plugin along with your jQuery library.

查看更多
够拽才男人
3楼-- · 2019-01-05 01:03

For simple IE detection I tend to use:

(/msie|trident/i).test(navigator.userAgent)

Visit the Microsoft Developer Network to learn about the IE useragent: http://msdn.microsoft.com/library/ms537503.aspx

查看更多
地球回转人心会变
4楼-- · 2019-01-05 01:05

The jQuery.browser options was deprecated earlier and removed in 1.9 release along with a lot of other deprecated items like .live.

For projects and external libraries which want to upgrade to 1.9 but still want to support these features jQuery have release a migration plugin for the time being.

If you need backward compatibility you can use migration plugin.

查看更多
做个烂人
5楼-- · 2019-01-05 01:07

I had this problem as well. We were using two versions of Jquery (1.11.3 and 1.8.3), one of which was causing this issue. I found a lightbox_me.js release that worked on both versions:

http://buckwilson.me/lightboxme/

It was just an easy replacement of an old file.

查看更多
做自己的国王
6楼-- · 2019-01-05 01:11

$.browser was deprecated in version 1.3 and removed in 1.9

You can verify this by viewing the documentation.

查看更多
孤傲高冷的网名
7楼-- · 2019-01-05 01:12

Using this:

if (navigator.userAgent.match("MSIE")) {}

查看更多
登录 后发表回答