Verify the version of Internet Explorer being used

Verify the version of Internet Explorer being used
Using JavaScript, this function verifies if the current version of Internet Explorer is the same one as the one passed through the function argument.
// True is being returned if the IE version is the one passed in ieVersion
function IeVersion(ieVersion)
{
        var currUserAgent = navigator.userAgent.toLowerCase();
        if(!(navigator && navigator.userAgent && navigator.userAgent.toLowerCase))
        {
                return false;
        }
        else
        {
                if(currUserAgent.indexOf('msie') + 1)
                {
                        var ver = function()
                        {
                                var rv = -1; // just in case the current browser is not Internet Explorer
                                if (navigator.appName == 'Microsoft Internet Explorer')
                                {
                                        var ua = navigator.userAgent;
                                        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
                                        if (re.exec(ua) != null)
                                        {
                                                rv = parseFloat( RegExp.$1 );
                                        }
                                }
                                return rv;
                        };
                        var valid = true;
                        if ((ver > -1) && (ver < ieVersion))
                        {
                                valid = false;
                        }
                        return valid;
            }
            else
            {
                        return false;
            }
        }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top