判断页面使用浏览器版本

来源:互联网 发布:vb编程入门教程 编辑:程序博客网 时间:2024/04/29 19:39

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head xmlns="">
    <title></title>

    <script>
function fun(){
 var Sys = {};
            var ua = navigator.userAgent.toLowerCase();
            if (window.ActiveXObject)//IE
                Sys.ie = ua.match(/msie ([/d.]+)/)[1]
            else if (document.getBoxObjectFor)  //火狐
                Sys.firefox = ua.match(/firefox//([/d.]+)/)[1]
            else if (window.MessageEvent && !document.getBoxObjectFor)//谷歌
                Sys.chrome = ua.match(/chrome//([/d.]+)/)[1]
            else if (window.opera)//Opera
                Sys.opera = ua.match(/opera.([/d.]+)/)[1]
            else if (window.openDatabase)//菜果
                Sys.safari = ua.match(/version//([/d.]+)/)[1];


                   alert(Sys.ie);//可判断浏览器版本
                }
    </script>

</head>
<body onload="fun();">
</body>
</html>

 

原创粉丝点击