Skip to content

Instantly share code, notes, and snippets.

@tzi
Created March 1, 2012 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tzi/1950913 to your computer and use it in GitHub Desktop.
Save tzi/1950913 to your computer and use it in GitHub Desktop.
Dectection of Internet Explorer version

If you want to try it, go here

<!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>
(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