Created
September 17, 2013 19:04
-
-
Save make-sum/6599149 to your computer and use it in GitHub Desktop.
IE browser detect, including ie version, and ie document mode.
This file contains 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
var ua = navigator.userAgent; | |
var isIE = ua.indexOf("MSIE") != -1; | |
var ieVersion; | |
var mode = document.documentMode || | |
((/back/i).test(document.compatMode || "") ? 5 : ieVersion) || | |
((/MSIE\s*(\d+\.?\d*)/i).test(navigator.userAgent || "") ? parseFloat(RegExp.$1, 10) : null); | |
function getIEVersion(dataString) { | |
var index = dataString.indexOf("MSIE"); | |
if (index == -1) return; | |
return parseFloat(dataString.substring(index+5)); | |
} | |
if(isIE) { | |
ieVersion = getIEVersion(navigator.userAgent); | |
//alert('version '+ ieVersion); | |
if(ieVersion < 10) { | |
//alert('document.documentMode ' + document.documentMode); | |
if(mode < 7 || !mode) { | |
//do something here, example | |
return; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment