简体   繁体   English

如果useragent是IE6,如何卸载/删除/替换Jquery脚本?

[英]How to unload/remove/replace a Jquery Script if useragent is IE6?

This is tricky. 这很棘手。 I have done a script with jQuery, where an gets "shaked" if the user puts incorrect values: 我已经用jQuery完成了一个脚本,如果用户输入了不正确的值,该脚本就会“摇晃”:

$('#input-name').addClass('input-bad').effect('shake',{
            direction: 'left',
            distance: 10,
            times: 3}
        , 100 );

The problem is that this effect (thanks to jQuery UI) makes the input shake but at the very far right of the page in Internet Explorer 6 (dunno 7/8). 问题在于,这种效果(由于使用jQuery UI)使输入摇晃,但在Internet Explorer 6(dunno 7/8)页面的最右侧。 The point is remove the shake effect if the user uses this browser. 关键是,如果用户使用此浏览器,则消除抖动效果。 I'm using for browser detection purposes. 我用于浏览器检测。

You may want to ensure you are looking at the major revision, ie 6 . 您可能要确保您正在查看的主要修订版本,即6

if ($.browser.msie && parseInt($.browser.version, 10) == 6) {
   // IE6
}

You could also use conditional comment... 您还可以使用条件注释...

<!--[if IE 6]>
  <script type="text/javascript">
     // IE6
  </script>
<![endif]-->
if($.browser.msie && $.browser.version=="6.0") {
    // maybe change color to indicate error?
}
else {
    $('#input-name').addClass('input-bad').effect('shake',{
            direction: 'left',
            distance: 10,
            times: 3}
        , 100 );
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM