Jquery fail to detect IE 11

六月ゝ 毕业季﹏ 提交于 2019-11-27 04:29:45
Ehud Grand

The final solution:

if (!!navigator.userAgent.match(/Trident\/7\./))
  return "ie";  

We can only hope that the release version will act the same.

mason

It's for compatibility reasons. Client code often performs browser detection instead of feature detection (which is a poor practice). So in an effort to make sure that clients properly use all of IE 11's capabilities Microsoft has made it so that IE 11 will report that it's Mozilla compatible.

So instead of doing browser detection, do feature detection. See Browser detection versus feature detection. There's some great libraries for that, with Modernizr probably being the most well known (and Microsoft ships it as part of the ASP.NET templates in Visual Studio).

See MSDN blog about IE 11 User Agent Strings.

The purpose of jQuery Migrate is to allow old badly-written code to run, not to encourage writing new badly-written code. Since that old badly-written code was created long before IE11 was released, it doesn't know about IE11 anyway and will probably misbehave regardless. The jQuery Migrate plugin won't be changed to detect IE11. If you are writing new code, don't use browser detection. Instead, use feature detection.

jQuery.browser is long deprecated and has been removed, you should use $.support or a better tool like Modernizr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!