开发者

How to disable a jQuery function in IE7 only?

I have a jQuery function that is causing display errors in IE7. I simply want to disable the function only for IE7 instead of dealing with fixing the display errors.

Here is the code that calls the function:

$(documen开发者_如何转开发t).ready(function() {
    $("select, input:checkbox, input:radio, input:file").uniform();
});

So, what's the best practice to target that callout and disable it for IE7 only?


jQuery.browser allows you to view the user agent version, though it's not recommended by the jQuery team. Instead look at jQuery.support which is recommended for 'feature detection' to determine which browser you're using.

Using $.browser, something like (not tested):

if ( !($.browser.msie && $.browser.version == 7.0) ){
...
}

Would do the trick


It's never fun, but this will work...

<!--[if IE 7]>
<script type="text/javascript">
  $.fn.uniform = function() { }
</script>
<![endif]-->

Browser detection via Javascript is never reliable, but this should be since it is a valid markup comment and IE is the only browser (that I know of) sniffing for it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜