본문 바로가기
코드 간편모음

browser detect 코드

by 찬찬2 2020. 8. 20.

브라우저 detect!!

 

<!-- <script>

                     var browserType = ['MSIE', 'Trident', 'Edge'];

                     var detect, IEx = navigator.userAgent;

                     var IEstyleSheet = document.querySelector('.alternate-style');

 

                     for(var i = 0; i < browserType.length; i++){

                                if(IEx.indexOf(browserType[i]) > -1){

                                           detect = browserType[i];

                                           console.log(detect);

                                           break;

                                }

                     }

                     if(detect == 'MSIE' || detect == 'Trident' || detect == 'Edge' ){

                                detect = 'Internet Explorer'; // 익스플로러 버전이 바뀔 경우, 위 단어가 아닐 경우 위험!! //

                                console.log('working?');

                                //익스플로러 버전을 구체적으로 확인하지 않는 방법.

 

                                detectIE();

                                function detectIE (){

                                           if(detect = 'Internet Explorer'){

                                                     IEstyleSheet.removeAttribute('disabled');

                                           }else{

                                                     IEstyleSheet.setAttribute('disabled', true);

                                           }

                                }

                     }

           </script> -->

댓글