Skip to content

Instantly share code, notes, and snippets.

@misner
Forked from padolsey/gist:527683
Created January 3, 2013 09:47

Revisions

  1. misner revised this gist Jan 3, 2013. No changes.
  2. @padolsey padolsey revised this gist Aug 21, 2010. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -18,8 +18,6 @@

    var ie = (function(){

    if (/*@cc_on!@*/true) return undef;

    var undef,
    v = 3,
    div = document.createElement('div'),
  3. @padolsey padolsey revised this gist Aug 21, 2010. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -15,14 +15,13 @@
    // ----------------------------------------------------------

    // UPDATE: Now using Live NodeList idea from @jdalton
    // and conditional compilation early exit from Scott Jehl

    var ie = (function(){

    if (/*@cc_on!@*/true) return undef;

    var undef,
    v = 4,
    v = 3,
    div = document.createElement('div'),
    all = div.getElementsByTagName('i');

    @@ -31,6 +30,6 @@ var ie = (function(){
    all[0]
    );

    return v;
    return v > 4 ? v : undef;

    }());
  4. @padolsey padolsey revised this gist Aug 20, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@
    // ie < 9 // Anything less than IE9
    // ----------------------------------------------------------

    // UPDATE: Now using Live NodeList idea from @Dalton
    // UPDATE: Now using Live NodeList idea from @jdalton
    // and conditional compilation early exit from Scott Jehl

    var ie = (function(){
  5. @padolsey padolsey revised this gist Aug 20, 2010. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,7 @@
    // ----------------------------------------------------------
    // A short snippet for detecting versions of IE in JavaScript
    // without resorting to user-agent sniffing
    // ----------------------------------------------------------
    // If you're not in IE (or IE version is less than 5) then:
    // ie === undefined
    // If you're in IE (>=5) then you can determine which version:
  6. @padolsey padolsey revised this gist Aug 20, 2010. 1 changed file with 13 additions and 5 deletions.
    18 changes: 13 additions & 5 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -11,15 +11,23 @@
    // ie < 9 // Anything less than IE9
    // ----------------------------------------------------------

    // UPDATE: Now using Live NodeList idea from @Dalton
    // and conditional compilation early exit from Scott Jehl

    var ie = (function(){

    var undef, v = 3, div = document.createElement('div');

    if (/*@cc_on!@*/true) return undef;

    var undef,
    v = 4,
    div = document.createElement('div'),
    all = div.getElementsByTagName('i');

    while (
    div.innerHTML = '<!--[if gt IE '+(++v)+']><i></i><![endif]-->',
    div.getElementsByTagName('i')[0]
    div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
    all[0]
    );

    return v > 4 ? v : undef;
    return v;

    }());
  7. @padolsey padolsey revised this gist Aug 17, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ----------------------------------------------------------
    // If you're not in IE (or IE version is less than 5) then:
    // ie === undefined
    // If you're in IE (>5) then you can determine which version:
    // If you're in IE (>=5) then you can determine which version:
    // ie === 7; // IE7
    // Thus, to detect IE:
    // if (ie) {}
  8. @padolsey padolsey revised this gist Aug 16, 2010. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -6,14 +6,14 @@
    // Thus, to detect IE:
    // if (ie) {}
    // And to detect the version:
    // ie && ie === 6 // IE6
    // ie && ie > 7 // IE8, IE9 ...
    // ie && ie < 9 // Anything less than IE9
    // ie === 6 // IE6
    // ie > 7 // IE8, IE9 ...
    // ie < 9 // Anything less than IE9
    // ----------------------------------------------------------

    var ie = (function(){

    var undef, v = 4, div = document.createElement('div');
    var undef, v = 3, div = document.createElement('div');

    while (
    div.innerHTML = '<!--[if gt IE '+(++v)+']><i></i><![endif]-->',
  9. @padolsey padolsey revised this gist Aug 16, 2010. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -6,9 +6,9 @@
    // Thus, to detect IE:
    // if (ie) {}
    // And to detect the version:
    // ie === 6 // IE6
    // ie > 7 // IE8, IE9 ...
    // ie < 9 // Anything less than IE9
    // ie && ie === 6 // IE6
    // ie && ie > 7 // IE8, IE9 ...
    // ie && ie < 9 // Anything less than IE9
    // ----------------------------------------------------------

    var ie = (function(){
  10. @padolsey padolsey created this gist Aug 16, 2010.
    25 changes: 25 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    // ----------------------------------------------------------
    // If you're not in IE (or IE version is less than 5) then:
    // ie === undefined
    // If you're in IE (>5) then you can determine which version:
    // ie === 7; // IE7
    // Thus, to detect IE:
    // if (ie) {}
    // And to detect the version:
    // ie === 6 // IE6
    // ie > 7 // IE8, IE9 ...
    // ie < 9 // Anything less than IE9
    // ----------------------------------------------------------

    var ie = (function(){

    var undef, v = 4, div = document.createElement('div');

    while (
    div.innerHTML = '<!--[if gt IE '+(++v)+']><i></i><![endif]-->',
    div.getElementsByTagName('i')[0]
    );

    return v > 4 ? v : undef;

    }());