开发者

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:

$('#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). 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, i.e. 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 );
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜