If you want to try it, go here
Created
March 1, 2012 16:13
-
-
Save tzi/1950913 to your computer and use it in GitHub Desktop.
Dectection of Internet Explorer version
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Test navigator</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
</head> | |
<body> | |
<script type="text/javascript" src="internet_explorer_version.js"></script> | |
<body> | |
</html> |
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
(function() { | |
var is_valid_navigator = function( ) { | |
// UTILS | |
var is_internet_explorer = function( ) { | |
return ( window.navigator.appName == 'Microsoft Internet Explorer' ); | |
} | |
var get_internet_explorer_version = function( ) { | |
var matches = new RegExp( ' MSIE ([0-9]\.[0-9]);' ).exec( window.navigator.userAgent ); | |
if ( matches != null && matches.length > 1 ) { | |
return matches[ 1 ]; | |
} | |
return false; | |
} | |
// LOGIC | |
if ( is_internet_explorer( ) ) { | |
return ( get_internet_explorer_version( ) > 8 ); | |
} | |
return true; | |
} | |
if ( is_valid_navigator( ) ) { | |
document.write( 'Valid navigator' ); | |
} else { | |
document.write( 'navigator not valid' ); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment