I'm developing a plugin for jQuery, and because of a bug (not sure if it's a bug in IE or in jQuery) I need to detect whether the plugin is used in IE or not.
A comprised version of the background: My plugin needs to handle the current value for the CSS property clip. Normally you'd do something like value = $('#my-element').css('clip');. But if the clip value contains the (permitted) value auto, the return value gets compromised: Every auto gets changed into 0px.
Say, the CSS sets the element to clip: rect(0px, 50px, auto, 0px). In current Firefox, value = $('#my-element').css('clip'); returns correctly rect(0px, 50px, auto, 0px). But in IE I get rect(0px, 50px, 0px, 0px). Of course, this throws everything off course. In my tests all IE version from 8 to 11 showed this problem, as well as the most current versions of jQuery.
Luckily, you get the correct value if you use the IE-specific currentStyle, e. g. value = $('#my-element').get(0).currentStyle.clip. But because it's IE-specific, all the other browsers get tripped by that.
So, I need a way to detect whether my jQuery plugin is run in IE, regardless of version, or not. So far I found that looking for htmls currentStyle is working, along the lines of
if(document.getElementsByTagName("html")[0].currentStyle) {
  // do IE-stuff
} else
{
  // do it the general way
}
But that seems quite wonky and not very elegant to me. Does anybody know about a better solution to detect the Internet Explorer?
 
     
    