I used the below code and every thing worked fine. This is working on all the IE versions (Tested and Verified :) ).
//Checks the document mode of the IE and displays an error if the doc mode is not supported
function CheckDocMode() {
//Get the browser name
var browserName = navigator.appName;
//Do not display the Div containing the error message
document.getElementById('DocModeError').style.display = 'none';
//Check if the browser is IE
if (browserName == "Microsoft Internet Explorer") {
//Get the IE version, document mode and complatibility mode
var IEVersion = GetIEVersion();
var IEDocMode = document.documentMode;
var IECompatibilityMode = document.compatMode;
//Confirm that the browser is IE8/9/10
if (IEDocMode != undefined) {
//Do not display the error message if the IE=10 and Doc Mode = Standard
if ((IEVersion == 10 || IEVersion == 9 || IEVersion == 8 || IEVersion == 7)
&& (IEDocMode == 10 && IECompatibilityMode == "CSS1Compat")) {
return;
}
//Display the error if the document mode is anything other than IE8 and IE9
if (IEDocMode != 8 && IEDocMode != 9) {
document.getElementById('DocModeError').style.display = 'block';
}
}
}
}
function GetIEVersion() {
var myNav = navigator.userAgent.toLowerCase();
return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
}