2017-05-05 66 views
-1

我正在使用jquery-resizable插件: https://github.com/RickStrahl/jquery-resizable。按照下面的代码加载它。如何仅在IE10中加载插件+

在IE10中,我想忽略它。如何只在IE11 +和其他普通浏览器中加载插件? MS不再支持条件注释...它可以是JS或JQ解决方案。

$(".mu-panel-left").resizable({ 
     handleSelector: ".mu-splitter", 
     resizeHeight: false 
    }); 

    $(".mu-panel-top").resizable({ 
     handleSelector: ".mu-splitter-horizontal", 
     resizeWidth: false 
    }); 

编辑: 难道则是更好的补充CSS一样:

@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { 
    /* IE10+ only: assign X to body */ 
} 

,然后用JQ检查,如果身体有类X,如果是的话那么它的IE10 +?

+0

也许你可以用特征检测尝试。尝试modernizr为此:https://modernizr.com/ –

回答

0

我不应该容易受到欺骗的解决方案。

CSS

#x {margin-bottom:0;} 

/* IE 10+ only */ 
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { 
    #x {margin-bottom:1px;} 
} 

JQ

var marg = parseInt($('#x').css("marginBottom")); 
    if (marg == 0) { alert ('not ie');} 
    else {alert('ie 10');} 
    // then do whatever 
0

如果导航器IE10 VAR is_ie10 ==真,否则该代码将检查导航器IE10与否是假 ,所以你可以检查is_ie10是否含有虚假,你可以执行功能

function getIEVersion(){ 
    var agent = navigator.userAgent; 
    var reg = /MSIE\s?(\d+)(?:\.(\d+))?/i; 
    var matches = agent.match(reg); 
    if (matches != null) { 
     return { major: matches[1], minor: matches[2] }; 
    } 
    return { major: "-1", minor: "-1" }; 
} 

var ie_version = getIEVersion(); 
var is_ie10 = ie_version.major == 10; 

PS我们使用navigator.userAgent来确定平台,它很容易受到用户的欺骗或者浏览器本身的错误陈述。尽可能避免浏览器特定的代码。

有关更多信息,请this

+0

那么使用我添加的CSS解决方法会更好吗? – janeh

+0

使用css添加html类是不可能的;所以你必须使用javascript处理它 –

+0

我想我有另一种解决方案,请参阅下面的内容: – janeh