Skip to main content

Tiny library to automatically detect Internet Explorer version and bring us a sure way to use polyfills and IE CSS fixes.

/* ============================================================================
    Internet Explorer version detector

    ClassIE 0.3.2 (https://github.com/pyrsmk/ClassIE)

    The IE variable is available to know under which version of Internet
    Explorer your script is loaded.

        if (IE <= 8) {
            // some polyfills
        }

    For browsers other than IE or ulterior to 9, IE variable will return -1.

    CSS

    Then, using ClassIE with your stylesheets is pretty simple:

        .ie6 #contents,
        .ie7 #contents {
          // some specific properties
        }
============================================================================ */

this.IE=-1;/*@cc_on
(function() {
    var div = document.createElement('div'),
        is = function(version) {
            div.innerHTML = '<!--[if IE ' + version + ']>1<![endif]-->';
            return div.innerHTML == 1;
        },
        version = 6;
    // Consider IE5.5 as IE6
    if (!is('5.5000')) {
        // Let's find the current IE version
        while (!is(version) && ++version < 10) {}
    }
    // CSS side
    document.documentElement.className += ' ie' + version;
    // JS side
    this.IE = version;
})();
@*/