我是靠谱客的博主 强健大山,这篇文章主要介绍javaScript判断当前浏览器(谷歌、火狐、IE)兼容IE11,现在分享给大家,希望可以做个参考。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>判断当前浏览器是否为IE</title>
        <script type="text/javascript">
            window.onload = function(){
                var ua = navigator.userAgent;
                console.log(ua);
                 // * Chrome--
                 // *    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36
                 // *
                 // * Firefox--
                 // *    Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0
                 // *
                 // * IE11--
                 // *  Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; Tablet PC 2.0; rv:11.0) like Gecko
                 // * 
                 // * IE10
                 // *  Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; Tablet PC 2.0)
                 // *
                 // * IE9
                 // *  Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; Tablet PC 2.0)
                 // *
                 // * IE8
                 // *  Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; Tablet PC 2.0) 
                 // * 
                
                 if("ActiveXObject" in window){
                     alert("你是IE浏览器!");
                 }else{
                    if(/Chrome/i.test(ua)){
                        alert("你是Chrome浏览器!");
                    }else if(/Firefox/i.test(ua)){
                        alert("你是Firefox浏览器!");
                    } 
                 }
            };
        </script>
    </head>
    <body>
    </body>
</html>

最后

以上就是强健大山最近收集整理的关于javaScript判断当前浏览器(谷歌、火狐、IE)兼容IE11的全部内容,更多相关javaScript判断当前浏览器(谷歌、火狐、IE)兼容IE11内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(113)

评论列表共有 0 条评论

立即
投稿
返回
顶部