Last active
January 10, 2018 08:24
-
-
Save carloscabo/1b92432965e141d03f27771b6212b98f to your computer and use it in GitHub Desktop.
Detects JS support and IE10/11 browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
<html xml:lang="es" lang="es" class="not-ie no-js"> | |
Replaces the `no-js` by `js` if browser has JS support and the `not-ie` by `ie` if we are in IE browser | |
Conditional comments are no longer supported in IE10 / 11 https://msdn.microsoft.com/en-us/library/hh801214(v=vs.85).aspx | |
Is recommended to be the FIRST js script app ;) | |
*/ | |
(function(){ | |
var | |
ua = window.navigator.userAgent; | |
document.documentElement.className = document.documentElement.className.replace('no-js', 'js'); | |
if ( ua.indexOf('MSIE ') > 0 || ua.indexOf('Trident/') > 0 ) { | |
// Is IE 10 /11 | |
document.documentElement.className = document.documentElement.className.replace('not-ie', 'ie'); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do not assign
document.documentElement.className
to a variable, seems that in some versions of IE does not work the.replace
if it is not done over thedocument.documentElement.className
property directly.