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;
            }
        }
}
Nathan Pakovskie is an esteemed senior developer and educator in the tech community, best known for his contributions to Geekpedia.com. With a passion for coding and a knack for simplifying complex tech concepts, Nathan has authored several popular tutorials on C# programming, ranging from basic operations to advanced coding techniques. His articles, often characterized by clarity and precision, serve as invaluable resources for both novice and experienced programmers. Beyond his technical expertise, Nathan is an advocate for continuous learning and enjoys exploring emerging technologies in AI and software development. When he’s not coding or writing, Nathan engages in mentoring upcoming developers, emphasizing the importance of both technical skills and creative problem-solving in the ever-evolving world of technology. Specialties: C# Programming, Technical Writing, Software Development, AI Technologies, Educational Outreach

Leave a Reply

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

Back To Top