IE 检测

<div id="kie-bar" style="display: none;">
    您现在使用的浏览器版本过低,可能会导致部分图片和信息的缺失。</div>

<script type="text/javascript">
    function IEMode() {
        var ua = navigator.userAgent.toLowerCase();
        var re_trident = /\btrident\/([0-9.]+)/;
        var re_msie = /\b(?:msie |ie |trident\/[0-9].*rv[ :])([0-9.]+)/;
        var version;
        if (!re_msie.test(ua)) {
            return false;
        }
        var m = re_trident.exec(ua);
        if (m) {
            version = m[1].split(".");
            version[0] = parseInt(version[0], 10) + 4;
            version = version.join(".");
        } else {
            m = re_msie.exec(ua);
            version = m[1];
        }
        return parseFloat(version);
    }
    var ie = IEMode();
    if (ie && ie < 8) {
        document.getElementById('kie-bar').style.display = 'block';
    }
</script>


你可能感兴趣的:(IE 检测)