판단 브라우저

1965 단어
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

</body>
<script>


        function browser(){

            var brow=(window.navigator.userAgent);
                    document.write(brow);
            var  navIE=brow.indexOf('MSIE');
                if(navIE==-1){// IE
                    var navOP=brow.indexOf('OPR');
                    var navFF=brow.indexOf('Firefox');
                    var navCHR=brow.indexOf('Chrome');
                    var navSAF=brow.indexOf('Safari');
                    if(navOP!=-1){
                        alert("Opera");
                    }
                    else if(navFF!=-1){
                        alert("Firefox");
                    }
                    else if(navCHR!=-1&&navFF==-1){
                        alert("Chrome");
                    }
                    else(navCHR==-1&&navSAF!=-1)
                    alert("Safari");

                }
                else{//IE
                    /*var nav=brow.substr(brow.indexOf('IE'),4);
                    if(nav=="IE 6"){
                        alert("IE 6");
                    }
                    else if(nav=="IE 7"){
                        alert("IE 7");
                    }
                    else if(nav=="IE 8"){
                        alert("IE 8");
                    }
                    else
                    {
                        alert("IE ");
                    }*/// 
                    var start=brow.indexOf('MSIE')+2;// I 
                    var end=brow.indexOf(';',start);// IE 
                    alert(brow.slice(start,end));
                }
            }


    browser();
</script>
</html>

좋은 웹페이지 즐겨찾기