To check the IE 8.0 Version after install in server
Introduction
How to check IE 8.0 Version in javascript
Problem faced.
Last week I came across a problem, which stop to think. The problem is regarding the IE8 Version.
Using the javascript I had checked the IE version (navigator.userAgent) in my local machine.
Solution & Code
But, I got shocked when I run it from server, it display me as MSIE 7.0. After that I came to knew that
To check the version for IE8.0 we need to check the document.documentMode.
The documentmode property returns a numeric value corresponding to the page’s document compatibility mode.for ex if a page has chosen to support IE8 mode,documentMode return the value 8
function IEVersion()
{
Version = "NA";
if (window.navigator.appName == "Microsoft Internet Explorer")
{
// This is an IE browser. What mode is the engine in?
if (document.documentMode) // IE8
Version = document.documentMode;
else // IE 5-7
{
Version = 5; // Assume quirks mode unless proven otherwise
if (document.compatMode)
{
if (document.compatMode == "CSS1Compat")
Version = 7; // standards mode
}
}
}
return {
"Version" : Version
}
}
var ieVersion = IEVersion();
var IsIE8 = ieVersion.Version != "NA" && ieVersion.Version >= 8;
alert(IsIE8);
Conclusion
To check the version for IE8.0 use document.documentMode.