views:

179

answers:

2

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:

$(document).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?

+2  A: 

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

brad
Ryley
good call, made that one up pretty quickly... fixed
brad
This is great information. I think I might even need another push as to what to place within that statement to disable the function. Any ideas, I'm pretty new to this whole idea...
Adam
disregard that... figured it out.Thanks!
Adam
+1  A: 

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.

Josh Stodola