Tuesday, September 16, 2014

Check IE by Javascript

    function getInternetExplorerVersion()
    {
        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;
}


    function checkVersion()
    {
var msg = "The site is best viewed with Internet Explorer Version 6 and above.\n\nThe page might not be properly displayed if viewed on your current browser.";
      
var ver = getInternetExplorerVersion();

        if (ver > -1)
        {
            if (ver >= 6.0)
                msg = ""
        }

        if(msg != "")
        {
            alert(msg);
        }

}

No comments:

Post a Comment