Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.