Ext.isIE return false in IE 11

天涯浪子 提交于 2019-12-30 17:43:09

问题


When I try to use Ext.isIE in IE11 i get false the returning value. And then during the debug my code I see that I get the following error: JavaScript Error - Msg:Invalid argument., my extjs's version is: 4,2


回答1:


IE 11 is not officially supported prior to ExtJS 4.2.2 (see property isIE11). Microsoft removed the MSIE part from IE11's user agent (refer here), which is the reason why it does not work with ExtJS 4.2.1 and below.

From the source code, for ExtJS 4.2.1:

isIE = !isOpera && check(/msie/),
isIE7 = isIE && ((check(/msie 7/) && docMode != 8 && docMode != 9 && docMode != 10) || docMode == 7),
isIE8 = isIE && ((check(/msie 8/) && docMode != 7 && docMode != 9 && docMode != 10) || docMode == 8),
isIE9 = isIE && ((check(/msie 9/) && docMode != 7 && docMode != 8 && docMode != 10) || docMode == 9),
isIE10 = isIE && ((check(/msie 10/) && docMode != 7 && docMode != 8 && docMode != 9) || docMode == 10),
isIE6 = isIE && check(/msie 6/),

and for ExtJS 4.2.2:

isIE = !isOpera && (check(/msie/) || check(/trident/)),
isIE7 = isIE && ((check(/msie 7/) && docMode != 8 && docMode != 9 && docMode != 10) || docMode == 7),
isIE8 = isIE && ((check(/msie 8/) && docMode != 7 && docMode != 9 && docMode != 10) || docMode == 8),
isIE9 = isIE && ((check(/msie 9/) && docMode != 7 && docMode != 8 && docMode != 10) || docMode == 9),
isIE10 = isIE && ((check(/msie 10/) && docMode != 7 && docMode != 8 && docMode != 9) || docMode == 10),
isIE11 = isIE && ((check(/trident\/7\.0/) && docMode != 7 && docMode != 8 && docMode != 9 && docMode != 10) || docMode == 11),
isIE6 = isIE && check(/msie 6/),



回答2:


It's very simple:

navigator.userAgent.toLowerCase().lastIndexOf('rv:11') > -1

will return true if it's a IE11 browser.




回答3:


This works for me:

var isIE11 = window.location.hash = !!window.MSInputMethodContext;



来源:https://stackoverflow.com/questions/21881671/ext-isie-return-false-in-ie-11

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