五大浏览器js 判断IE、Firefox、Safari、Chrome、Opera

<html>
<head>
<script type="text/javascript">
function GetBrowserVersion()
{
    var Sys = {};
    var ua = navigator.userAgent.toLowerCase();
    window.ActiveXObject ? Sys.ie = ua.match(/msie ([\d.]+)/)[1] :
    document.getBoxObjectFor ? Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1] :
    window.MessageEvent && !document.getBoxObjectFor ? Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1] :
    window.opera ? Sys.opera = ua.match(/opera.([\d.]+)/)[1] :
    window.openDatabase ? Sys.safari = ua.match(/version\/([\d.]+)/)[1] : 0;
    if(Sys.ie) return('IE: '+Sys.ie);
    if(Sys.firefox)return('FF:'+Sys.firefox);
    if(Sys.chrome) return('CH:'+Sys.chrome);
    if(Sys.opera) return('OP:'+Sys.opera);
    if(Sys.safari) return('SA:'+Sys.safari);
}
alert(GetBrowserVersion());
</script>
</head>
<body>
aa
</body>
</html>

posted @ 2014-07-24 09:23  阳光小屋  阅读(168)  评论(0编辑  收藏  举报