Rate this script:  I Love it  /   I Hate it

Browser detect for IE versions


Code


function isIE(versionNumber) {
var detect = navigator.userAgent.toLowerCase();
if(!(navigator && navigator.userAgent && navigator.userAgent.toLowerCase)) {
                return false;
            } else {
                if(detect.indexOf('msie') + 1) {
                    // browser is internet explorer
                    var ver = function() {
                        // http://msdn.microsoft.com/workshop/author/dhtml/overview/browserdetection.asp
                        // Returns the version of Internet Explorer or a -1
                        // (indicating the use of another browser).
                        var rv = -1; // Return value assumes failure
                        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 the version can be found and the version is less than our version number it is invalid
                    if ((ver > -1) && (ver < versionNumber)) {
                        valid = false;
                    }
                    return valid;
                } else {
                    return false
                }
            }
}

 

 

 
Browser detect for IE versions scripts | Browser detect for IE versions snippet | Browser detect for IE versions example | Browser detect for IE versions tutorial | Browser detect for IE versions code